Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "cleanup stories & docs",
"packageName": "@fluentui/react-switch",
"email": "olfedias@microsoft.com",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type SwitchOnChangeData = {
};

// @public
export type SwitchProps = Omit<ComponentProps<Partial<SwitchSlots>, 'input'>, 'onChange'> & {
export type SwitchProps = Omit<ComponentProps<Partial<SwitchSlots>, 'input'>, 'checked' | 'defaultChecked' | 'onChange'> & {
checked?: boolean;
defaultChecked?: boolean;
labelPosition?: 'above' | 'after' | 'before';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export type SwitchOnChangeData = {
/**
* Switch Props
*/
export type SwitchProps = Omit<ComponentProps<Partial<SwitchSlots>, 'input'>, 'onChange'> & {
export type SwitchProps = Omit<
ComponentProps<Partial<SwitchSlots>, 'input'>,
'checked' | 'defaultChecked' | 'onChange'
> & {
Comment on lines +40 to +43

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we have own definition we need to exclude existing ones for checked & defaultChecked. It also solves problem with the description for props.

Before

image

After

image

/**
* Defines the controlled checked state of the Switch.
* If passed, Switch ignores the `defaultChecked` property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export { Disabled } from './SwitchDisabled.stories';
export { Label } from './SwitchLabel.stories';
export { LabelWrapping } from './SwitchLabelWrapping.stories';
export { Required } from './SwitchRequired.stories';
export { Themed } from './SwitchThemed.stories';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This story is redundant and does not match patterns that we have for other components. I removed it to avoid confusion. To check how a component looks in different themes customers can use the theme selector and exists on every page:

image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same was done for react-card in #23082.


export default {
title: 'Components/Switch',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
## Best practices
<details>
<summary>
Best Practices
</summary>

### Do
### Layout

### Don't
- When people need to perform extra steps for changes to take effect, use a check box instead. For example, if they must click a "Submit", "Next", or "OK" button to apply changes, use a check box.

### Content

- Only replace the On/Off labels if there are more specific labels for the setting. For example, you might use Show/Hide if the setting is "Show images".
- Keep descriptive text short and concise—two to four words; preferably nouns. For example, "Focused inbox" or "WiFi".

</details>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added best practices & component description, took it from existing docs (https://developer.microsoft.com/en-us/fluentui#/controls/web/toggle). We will probably need to follow up on it to cleanup, but it's better than we have currently:

image

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A switch represents a physical switch that allows someone to choose between two mutually exclusive options. For example, "On/Off" and "Show/Hide". Choosing an option should produce an immediate result.

This file was deleted.