forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace ToolbarRadio implementation by usage of toggle button a…
…s Radio (microsoft#25343) * feat: replace ToolbarRadio implementation by usage of toggle button as radio * chore: add changes * chore: remove and update api * chore: update handler types * chore: delete line * chore: update checked items type * chore: rename * chore: update api and remove disable flag from handle radio * chore: update snapshot
- Loading branch information
Showing
34 changed files
with
223 additions
and
289 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-toolbar-87c0c30d-e652-4dd1-8f2c-27bb19adcbe5.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "none", | ||
"comment": "feat: replace ToolbarRadio implementation by usage of toggle button as radio", | ||
"packageName": "@fluentui/react-toolbar", | ||
"email": "chassunc@microsoft.com", | ||
"dependentChangeType": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
packages/react-components/react-toolbar/src/ToolbarRadioButton.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './components/ToolbarRadioButton/index'; |
1 change: 0 additions & 1 deletion
1
packages/react-components/react-toolbar/src/ToolbarRadioGroup.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/react-components/react-toolbar/src/components/Toolbar/useToolbarContextValues.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
packages/react-components/react-toolbar/src/components/ToolbarRadio/ToolbarRadio.test.tsx
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
packages/react-components/react-toolbar/src/components/ToolbarRadio/ToolbarRadio.tsx
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
packages/react-components/react-toolbar/src/components/ToolbarRadio/ToolbarRadio.types.ts
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...onents/react-toolbar/src/components/ToolbarRadio/__snapshots__/ToolbarRadio.test.tsx.snap
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
packages/react-components/react-toolbar/src/components/ToolbarRadio/index.ts
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
packages/react-components/react-toolbar/src/components/ToolbarRadio/useToolbarRadioStyles.ts
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...ct-components/react-toolbar/src/components/ToolbarRadioButton/ToolbarRadioButton.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { ToolbarRadioButton } from './ToolbarRadioButton'; | ||
import { isConformant } from '../../common/isConformant'; | ||
import { ToggleButtonProps } from '@fluentui/react-button'; | ||
|
||
describe('ToolbarRadioButton', () => { | ||
isConformant({ | ||
Component: ToolbarRadioButton as React.FunctionComponent<ToggleButtonProps>, | ||
displayName: 'ToolbarRadioButton', | ||
disabledTests: ['component-has-static-classnames-object'], | ||
}); | ||
|
||
// TODO add more tests here, and create visual regression tests in /apps/vr-tests | ||
|
||
it('renders a default state', () => { | ||
const result = render( | ||
<ToolbarRadioButton name="name" value="value"> | ||
Default ToolbarRadio | ||
</ToolbarRadioButton>, | ||
); | ||
expect(result.container).toMatchSnapshot(); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
...s/react-components/react-toolbar/src/components/ToolbarRadioButton/ToolbarRadioButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as React from 'react'; | ||
import type { ToolbarRadioButtonProps } from './ToolbarRadioButton.types'; | ||
import type { ForwardRefComponent } from '@fluentui/react-utilities'; | ||
import { renderToggleButton_unstable } from '@fluentui/react-button'; | ||
import { useToolbarRadioButton_unstable } from './useToolbarRadioButton'; | ||
import { useToolbarRadioButtonStyles_unstable } from './useToolbarRadioButtonStyles'; | ||
|
||
/** | ||
* ToolbarRadioButton component | ||
*/ | ||
export const ToolbarRadioButton: ForwardRefComponent<ToolbarRadioButtonProps> = React.forwardRef((props, ref) => { | ||
const state = useToolbarRadioButton_unstable(props, ref); | ||
|
||
useToolbarRadioButtonStyles_unstable(state); | ||
return renderToggleButton_unstable(state); | ||
}) as ForwardRefComponent<ToolbarRadioButtonProps>; | ||
|
||
ToolbarRadioButton.displayName = 'ToolbarRadioButton'; |
20 changes: 20 additions & 0 deletions
20
...ct-components/react-toolbar/src/components/ToolbarRadioButton/ToolbarRadioButton.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { ComponentProps, ComponentState } from '@fluentui/react-utilities'; | ||
import { ToggleButtonProps, ButtonSlots, ToggleButtonState } from '@fluentui/react-button'; | ||
|
||
/** | ||
* ToolbarRadioButton Props | ||
*/ | ||
export type ToolbarRadioButtonProps = ComponentProps<ButtonSlots> & | ||
Partial<Pick<ToggleButtonProps, 'disabled' | 'disabledFocusable' | 'size'>> & { | ||
appearance?: 'primary' | 'subtle'; | ||
name: string; | ||
value: string; | ||
}; | ||
|
||
/** | ||
* State used in rendering ToolbarRadioButton | ||
*/ | ||
export type ToolbarRadioButtonState = ComponentState<Partial<ButtonSlots>> & | ||
ToggleButtonState & | ||
Required<Pick<ToggleButtonProps, 'checked'>> & | ||
Pick<ToolbarRadioButtonProps, 'name' | 'value'>; |
15 changes: 15 additions & 0 deletions
15
...-toolbar/src/components/ToolbarRadioButton/__snapshots__/ToolbarRadioButton.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ToolbarRadioButton renders a default state 1`] = ` | ||
<div> | ||
<button | ||
aria-pressed="false" | ||
class="fui-Button fui-ToggleButton" | ||
name="name" | ||
type="button" | ||
value="value" | ||
> | ||
Default ToolbarRadio | ||
</button> | ||
</div> | ||
`; |
2 changes: 2 additions & 0 deletions
2
packages/react-components/react-toolbar/src/components/ToolbarRadioButton/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './ToolbarRadioButton'; | ||
export * from './ToolbarRadioButton.types'; |
Oops, something went wrong.