Skip to content

Commit 2c6830c

Browse files
Merge pull request #7 from anthonyleung-dev/material-web-v2
feat: upgrade material/web to 2.0.0
2 parents 04d7e2a + 53c4d6b commit 2c6830c

File tree

13 files changed

+1628
-2334
lines changed

13 files changed

+1628
-2334
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.0.0] - 2024-08-13
11+
12+
### Changed
13+
- Updated the `@material/web` package to `2.0.0`
14+
- Removed the CSS import in `src/index.tsx`, Now the CSS import is optional.
15+
1016
## [1.0.10] - 2024-05-31
1117

1218
### Changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ yarn add react-material-web
2020

2121
Here's a quick example to get you started. After installing, you can import and use Material Components like any other React component.
2222

23+
We default to using the `@fontsource/roboto` and `material-symbols` in styles, if you want to use them, you can import them in your project:
2324
Add styles to your project:
2425
```tsx
2526
import 'react-material-web/styles'
2627
```
2728

29+
Or you can use the components without default styles.
30+
2831
Then, you can use the components like this:
2932

3033
```tsx

package-lock.json

Lines changed: 1583 additions & 2264 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"dependencies": {
6868
"@fontsource/roboto": "^5.0.12",
6969
"@lit/react": "^1.0.4",
70-
"@material/web": "^1.5.0",
71-
"material-symbols": "^0.17.1"
70+
"@material/web": "^2.0.0",
71+
"material-symbols": "^0.17.4"
7272
}
7373
}

src/components/core/button/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export interface MdElevatedButtonElement extends _MdElevatedButton {}
6565
* @param {string} target - Where to display the linked `href` URL for a link button. Common options include `_blank` to open in a new tab.
6666
* @param {boolean} trailingIcon - Whether to render the icon at the inline end of the label rather than the inline start.
6767
* @param {boolean} hasIcon - Whether to display the icon or not.
68+
* @param {string} softDisabled - Whether or not the button is "soft-disabled" (disabled but still focusable). https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
6869
* @param {string} type - The default behavior of the button. May be "text", "reset", or "submit" (default).
6970
* @param {string} value - The value added to a form with the button's name when the button submits a form.
7071
* @param {string} name - The name of the button.
@@ -92,6 +93,7 @@ export const MdOutlinedButton = createComponent({
9293
* @param {string} target - Where to display the linked `href` URL for a link button. Common options include `_blank` to open in a new tab.
9394
* @param {boolean} trailingIcon - Whether to render the icon at the inline end of the label rather than the inline start.
9495
* @param {boolean} hasIcon - Whether to display the icon or not.
96+
* @param {string} softDisabled - Whether or not the button is "soft-disabled" (disabled but still focusable). https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
9597
* @param {string} type - The default behavior of the button. May be "text", "reset", or "submit" (default).
9698
* @param {string} value - The value added to a form with the button's name when the button submits a form.
9799
* @param {string} name - The name of the button.
@@ -119,6 +121,7 @@ export const MdFilledButton = createComponent({
119121
* @param {string} target - Where to display the linked `href` URL for a link button. Common options include `_blank` to open in a new tab.
120122
* @param {boolean} trailingIcon - Whether to render the icon at the inline end of the label rather than the inline start.
121123
* @param {boolean} hasIcon - Whether to display the icon or not.
124+
* @param {string} softDisabled - Whether or not the button is "soft-disabled" (disabled but still focusable). https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
122125
* @param {string} type - The default behavior of the button. May be "text", "reset", or "submit" (default).
123126
* @param {string} value - The value added to a form with the button's name when the button submits a form.
124127
* @param {string} name - The name of the button.
@@ -146,6 +149,7 @@ export const MdTextButton = createComponent({
146149
* @param {string} href - The URL that the link button points to.
147150
* @param {string} target - Where to display the linked `href` URL for a link button. Common options include `_blank` to open in a new tab.
148151
* @param {boolean} trailingIcon - Whether to render the icon at the inline end of the label rather than the inline start.
152+
* @param {string} softDisabled - Whether or not the button is "soft-disabled" (disabled but still focusable). https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
149153
* @param {boolean} hasIcon - Whether to display the icon or not.
150154
* @param {string} type - The default behavior of the button. May be "text", "reset", or "submit" (default).
151155
* @param {string} value - The value added to a form with the button's name when the button submits a form.
@@ -173,6 +177,7 @@ export const MdFilledTonalButton = createComponent({
173177
* @param {string} href - The URL that the link button points to.
174178
* @param {string} target - Where to display the linked `href` URL for a link button. Common options include `_blank` to open in a new tab.
175179
* @param {boolean} trailingIcon - Whether to render the icon at the inline end of the label rather than the inline start.
180+
* @param {string} softDisabled - Whether or not the button is "soft-disabled" (disabled but still focusable). https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
176181
* @param {boolean} hasIcon - Whether to display the icon or not.
177182
* @param {string} type - The default behavior of the button. May be "text", "reset", or "submit" (default).
178183
* @param {string} value - The value added to a form with the button's name when the button submits a form.

src/components/core/chips/index.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ export const MdChipSet = createComponent({
8989
* @param {boolean} elevated - Whether or not the chip is elevated.
9090
* @param {boolean} removable - Whether or not the chip is removable.
9191
* @param {boolean} selected - Whether or not the chip is selected.
92+
* @param {string} softDisabled - Whether or not the button is "soft-disabled" (disabled but still focusable). https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
9293
* @param {boolean} disabled - Whether or not the chip is disabled. Disabled chips are not focusable, unless always-focusable is set.
93-
* @param {boolean} alwaysFocusable - When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
94-
* @param {string} label - The label of the chip.
94+
* @param {boolean} alwaysFocusable - (Deprecated: Use `softDisabled` instead of `alwaysFocusable` + `disabled`.) When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
95+
* @param {string} label - (Deprecated: Set text as content of the chip instead.) The label of the chip.
9596
* @param {() => void} handleTrailingActionFocus - Callback for when the trailing action is focused.
9697
* @param {string} ariaLabelRemove - Aria label for the remove button.
9798
*/
@@ -112,9 +113,10 @@ export const MdFilterChip = createComponent({
112113
* @param {string} target - The target of the link.(e.g. _blank, _self, _parent, _top
113114
* @param {boolean} removeOnly - Whether or not the chip is remove only.
114115
* @param {boolean} selected - Whether or not the chip is selected.
116+
* @param {string} softDisabled - Whether or not the button is "soft-disabled" (disabled but still focusable). https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
115117
* @param {boolean} disabled - Whether or not the chip is disabled. Disabled chips are not focusable, unless always-focusable is set.
116-
* @param {boolean} alwaysFocusable - When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
117-
* @param {string} label - The label of the chip.
118+
* @param {boolean} alwaysFocusable - (Deprecated: Use `softDisabled` instead of `alwaysFocusable` + `disabled`.) When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
119+
* @param {string} label - (Deprecated: Set text as content of the chip instead.) The label of the chip.
118120
* @param {() => void} handleTrailingActionFocus - Callback for when the trailing action is focused.
119121
* @param {string} ariaLabelRemove - Aria label for the remove button.
120122
*/
@@ -133,8 +135,9 @@ export const MdInputChip = createComponent({
133135
* @param {string} href - The URL that the chip links to.
134136
* @param {string} target - The target of the link.(e.g. _blank, _self, _parent, _top
135137
* @param {boolean} disabled - Whether or not the chip is disabled. Disabled chips are not focusable, unless always-focusable is set.
136-
* @param {boolean} alwaysFocusable - When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
137-
* @param {string} label - The label of the chip.
138+
* @param {string} softDisabled - Whether or not the button is "soft-disabled" (disabled but still focusable). https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
139+
* @param {boolean} alwaysFocusable - (Deprecated: Use `softDisabled` instead of `alwaysFocusable` + `disabled`.) When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
140+
* @param {string} label - (Deprecated: Set text as content of the chip instead.) The label of the chip.
138141
*/
139142
export const MdSuggestionChip = createComponent({
140143
react: React,
@@ -151,8 +154,9 @@ export const MdSuggestionChip = createComponent({
151154
* @param {string} href - The URL that the chip links to.
152155
* @param {string} target - The target of the link.(e.g. _blank, _self, _parent, _top
153156
* @param {boolean} disabled - Whether or not the chip is disabled. Disabled chips are not focusable, unless always-focusable is set.
154-
* @param {boolean} alwaysFocusable - When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
155-
* @param {string} label - The label of the chip.
157+
* @param {string} softDisabled - Whether or not the button is "soft-disabled" (disabled but still focusable). https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
158+
* @param {boolean} alwaysFocusable - (Deprecated: Use `softDisabled` instead of `alwaysFocusable` + `disabled`.) When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.
159+
* @param {string} label - (Deprecated: Set text as content of the chip instead.) The label of the chip.
156160
*/
157161
export const MdAssistChip = createComponent({
158162
react: React,

src/components/core/chips/stories/md-assist-chip.stories.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,6 @@ const meta = {
3535
description:
3636
'Whether or not the chip is disabled. Disabled chips are not focusable, unless always-focusable is set.',
3737
},
38-
alwaysFocusable: {
39-
control: 'boolean',
40-
defaultValue: false,
41-
description:
42-
'When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.',
43-
},
44-
label: {
45-
control: 'text',
46-
description: 'The label of the chip.',
47-
defaultValue: '',
48-
},
4938
},
5039
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
5140
args: {},
@@ -56,18 +45,15 @@ type Story = StoryObj<typeof meta>
5645

5746
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
5847
export const Detault: Story = {
59-
args: {
60-
label: 'Assist Chip',
61-
},
48+
args: {},
49+
render: (props) => <MdAssistChip {...props}>Assist Chip</MdAssistChip>,
6250
}
6351

6452
export const WithIcon: Story = {
65-
args: {
66-
label: 'Assist Chip with Icon',
67-
},
6853
render: (props) => (
6954
<MdAssistChip {...props}>
7055
<MdIcon slot="icon">local_laundry_service</MdIcon>
56+
Assist Chip
7157
</MdAssistChip>
7258
),
7359
}

src/components/core/chips/stories/md-filter-chip.stories.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react'
2+
13
import type { Meta, StoryObj } from '@storybook/react'
24
import { MdFilterChip, MdFilterChipProps } from '..'
35

@@ -34,17 +36,6 @@ const meta = {
3436
description:
3537
'Whether or not the chip is disabled. Disabled chips are not focusable, unless always-focusable is set.',
3638
},
37-
alwaysFocusable: {
38-
control: 'boolean',
39-
defaultValue: false,
40-
description:
41-
'When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.',
42-
},
43-
label: {
44-
control: 'text',
45-
description: 'The label of the chip.',
46-
defaultValue: '',
47-
},
4839
ariaLabelRemove: {
4940
control: 'text',
5041
description: 'Aria label for the remove button.',
@@ -59,7 +50,6 @@ type Story = StoryObj<typeof meta>
5950

6051
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
6152
export const Detault: Story = {
62-
args: {
63-
label: 'Filter Chip',
64-
},
53+
args: {},
54+
render: ({ ...args }) => <MdFilterChip {...args}>Filter Chip</MdFilterChip>,
6555
}

src/components/core/chips/stories/md-input-chip.stories.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@ const meta = {
5050
description:
5151
'When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.',
5252
},
53-
label: {
54-
control: 'text',
55-
description: 'The label of the chip.',
56-
defaultValue: '',
57-
},
58-
ariaLabelRemove: {
59-
control: 'text',
60-
description: 'Aria label for the remove button.',
61-
},
6253
},
6354
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
6455
args: {
@@ -71,21 +62,19 @@ type Story = StoryObj<typeof meta>
7162

7263
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
7364
export const Detault: Story = {
74-
args: {
75-
label: 'Input Chip',
76-
},
65+
args: {},
7766
}
7867

7968
export const WithAvatar: Story = {
8069
args: {
81-
label: 'Input Chip with Avatar',
8270
avatar: true,
8371
disabled: false,
8472
},
8573
render: ({ ...args }) => (
8674
<MdChipSet>
8775
<MdInputChip {...args}>
8876
<img slot="icon" src="https://lh3.googleusercontent.com/a/default-user=s48" />
77+
Input Chip with Avatar
8978
</MdInputChip>
9079
</MdChipSet>
9180
),

src/components/core/chips/stories/md-suggestion-chip.stories.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@ const meta = {
3434
description:
3535
'Whether or not the chip is disabled. Disabled chips are not focusable, unless always-focusable is set.',
3636
},
37-
alwaysFocusable: {
38-
control: 'boolean',
39-
defaultValue: false,
40-
description:
41-
'When true, allow disabled chips to be focused with arrow keys. Add this when a chip needs increased visibility when disabled. See https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls for more guidance on when this is needed.',
42-
},
43-
label: {
44-
control: 'text',
45-
description: 'The label of the chip.',
46-
defaultValue: '',
47-
},
4837
},
4938
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
5039
args: {},
@@ -55,7 +44,6 @@ type Story = StoryObj<typeof meta>
5544

5645
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
5746
export const Detault: Story = {
58-
args: {
59-
label: 'Suggestion Chip',
60-
},
47+
args: {},
48+
render: ({ ...args }) => <MdSuggestionChip {...args}>Suggestion Chip</MdSuggestionChip>,
6149
}

0 commit comments

Comments
 (0)