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": "update snapshots",
"packageName": "@fluentui/react-checkbox",
"email": "olfedias@microsoft.com",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "export static classes for components",
"packageName": "@fluentui/react-label",
"email": "olfedias@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "export static classes for components",
"packageName": "@fluentui/react-switch",
"email": "olfedias@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Checkbox renders a default state 1`] = `
<div>
<label
class="fui-Checkbox"
class="fui-Label fui-Checkbox"
>
<div
class=""
Expand Down Expand Up @@ -36,7 +36,7 @@ exports[`Checkbox renders a default state 1`] = `
exports[`Checkbox renders checked correctly 1`] = `
<div>
<label
class="fui-Checkbox"
class="fui-Label fui-Checkbox"
>
<div
class=""
Expand Down Expand Up @@ -70,7 +70,7 @@ exports[`Checkbox renders checked correctly 1`] = `
exports[`Checkbox renders mixed correctly 1`] = `
<div>
<label
class="fui-Checkbox"
class="fui-Label fui-Checkbox"
>
<div
class=""
Expand Down Expand Up @@ -107,7 +107,7 @@ exports[`Checkbox renders mixed correctly 1`] = `
exports[`Checkbox renders unchecked correctly 1`] = `
<div>
<label
class="fui-Checkbox"
class="fui-Label fui-Checkbox"
>
<div
class=""
Expand Down
3 changes: 3 additions & 0 deletions packages/react-label/etc/react-label.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import * as React_2 from 'react';
// @public
export const Label: ForwardRefComponent<LabelProps>;

// @public (undocumented)
export const labelClassName = "fui-Label";

// @public
export type LabelCommons = {
disabled: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Label renders a custom asterisk 1`] = `
<body>
<div>
<label
class=""
class="fui-Label"
data-testid="label-id"
>
I'm a label
Expand All @@ -21,7 +21,7 @@ exports[`Label renders a custom asterisk 1`] = `
exports[`Label renders a default state 1`] = `
<div>
<label
class=""
class="fui-Label"
>
Default Label
</label>
Expand Down
3 changes: 3 additions & 0 deletions packages/react-label/src/components/Label/useLabelStyles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';
import type { LabelState } from './Label.types';

export const labelClassName = 'fui-Label';

/**
* Styles for the label
*/
Expand Down Expand Up @@ -46,6 +48,7 @@ const useStyles = makeStyles({
export const useLabelStyles = (state: LabelState): LabelState => {
const styles = useStyles();
state.root.className = mergeClasses(
labelClassName,
styles.root,
state.disabled && styles.disabled,
styles[state.size],
Expand Down
8 changes: 4 additions & 4 deletions packages/react-switch/Spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ Amongst other major component libraries (`Material UI`, `Ant Design`, `Evergreen
- _**DOM**_

```jsx=
<div className="ms-switch-root">
<div className="ms-switch-track" />
<div className="ms-switch-thumbWrapper">
<div className="ms-switch-thumb" />
<div className="fui-Switch">
<div className="fui-Switch-track" />
<div className="fui-Switch-thumbWrapper">
<div className="fui-Switch-thumb" />
</div>
<input type="checkbox" />
</div>;
Expand Down
3 changes: 3 additions & 0 deletions packages/react-switch/etc/react-switch.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const renderSwitch: (state: SwitchState) => JSX.Element;
// @public
export const Switch: ForwardRefComponent<SwitchProps>;

// @public (undocumented)
export const switchClassName = "fui-Switch";

// @public (undocumented)
export interface SwitchCommons {
checked?: boolean;
Expand Down
14 changes: 7 additions & 7 deletions packages/react-switch/src/Switch.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ const useIosStyles = makeStyles({
width: '50px',
height: '30px',

':hover .ms-Switch-thumb': {
':hover .fui-Switch-thumb': {
':before': {
background: 'white',
},
},

':active .ms-Switch-thumb': {
':active .fui-Switch-thumb': {
':before': {
background: 'white',
},
},

':hover .ms-Switch-track': {
':hover .fui-Switch-track': {
// Unchecked
':before': {
borderColor: 'none',
Expand All @@ -43,7 +43,7 @@ const useIosStyles = makeStyles({
},
},

':active .ms-Switch-track': {
':active .fui-Switch-track': {
':before': {
borderColor: 'none',
},
Expand Down Expand Up @@ -92,7 +92,7 @@ const useMaterialStyles = makeStyles({
width: '34px',
height: '14px',

':hover .ms-Switch-thumb': {
':hover .fui-Switch-thumb': {
':before': {
background: 'white',
},
Expand All @@ -101,7 +101,7 @@ const useMaterialStyles = makeStyles({
},
},

':hover .ms-Switch-track': {
':hover .fui-Switch-track': {
':before': {
background: '#9f9f9f',
},
Expand All @@ -111,7 +111,7 @@ const useMaterialStyles = makeStyles({
},
},

':active .ms-Switch-track': {
':active .fui-Switch-track': {
':before': {
background: '#9f9f9f',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
exports[`Switch Snapshot Tests renders a basic Switch checked 1`] = `
<div>
<div
class="ms-Switch-root checked"
class="fui-Switch checked"
id="switch-1"
>
<div
class="ms-Switch-track"
class="fui-Switch-track"
/>
<div
class=""
style="transform: translate(100%); transition: transform .1s cubic-bezier(0.33, 0.0, 0.67, 1), opacity .1s cubic-bezier(0.33, 0.0, 0.67, 1);"
>
<div
class="ms-Switch-thumb"
class="fui-Switch-thumb"
/>
</div>
<input
Expand All @@ -34,18 +34,18 @@ exports[`Switch Snapshot Tests renders a basic Switch checked 1`] = `
exports[`Switch Snapshot Tests renders a basic Switch unchecked 1`] = `
<div>
<div
class="ms-Switch-root"
class="fui-Switch"
id="switch-1"
>
<div
class="ms-Switch-track"
class="fui-Switch-track"
/>
<div
class=""
style="transform: translate(0%); transition: transform .1s cubic-bezier(0.33, 0.0, 0.67, 1), opacity .1s cubic-bezier(0.33, 0.0, 0.67, 1);"
>
<div
class="ms-Switch-thumb"
class="fui-Switch-thumb"
/>
</div>
<input
Expand All @@ -64,18 +64,18 @@ exports[`Switch Snapshot Tests renders a basic Switch unchecked 1`] = `
exports[`Switch Snapshot Tests renders a disabled Switch checked 1`] = `
<div>
<div
class="ms-Switch-root checked"
class="fui-Switch checked"
id="switch-1"
>
<div
class="ms-Switch-track"
class="fui-Switch-track"
/>
<div
class=""
style="transform: translate(100%); transition: transform .1s cubic-bezier(0.33, 0.0, 0.67, 1), opacity .1s cubic-bezier(0.33, 0.0, 0.67, 1);"
>
<div
class="ms-Switch-thumb"
class="fui-Switch-thumb"
/>
</div>
<input
Expand All @@ -95,18 +95,18 @@ exports[`Switch Snapshot Tests renders a disabled Switch checked 1`] = `
exports[`Switch Snapshot Tests renders a disabled Switch unchecked 1`] = `
<div>
<div
class="ms-Switch-root"
class="fui-Switch"
id="switch-1"
>
<div
class="ms-Switch-track"
class="fui-Switch-track"
/>
<div
class=""
style="transform: translate(0%); transition: transform .1s cubic-bezier(0.33, 0.0, 0.67, 1), opacity .1s cubic-bezier(0.33, 0.0, 0.67, 1);"
>
<div
class="ms-Switch-thumb"
class="fui-Switch-thumb"
/>
</div>
<input
Expand Down
16 changes: 8 additions & 8 deletions packages/react-switch/src/components/Switch/useSwitchStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';
import { createFocusOutlineStyle } from '@fluentui/react-tabster';
import type { SwitchState } from './Switch.types';

const rootClassName = 'ms-Switch-root';
const trackClassName = 'ms-Switch-track';
const thumbClassName = 'ms-Switch-thumb';
export const switchClassName = 'fui-Switch';
const trackClassName = `${switchClassName}-track`;
const thumbClassName = `${switchClassName}-thumb`;
Comment on lines +6 to +7

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we export these too?

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.

May be, but not in this PR. If we would like to do this, we should have some naming convention/consistency around it, see #19937 (comment).


/**
* Styles for the root slot
Expand All @@ -27,27 +27,27 @@ const useRootStyles = makeStyles({
}),

unchecked: theme => ({
':hover .ms-Switch-thumb': {
[`:hover .${thumbClassName}`]: {
':before': {
background: theme.colorNeutralStrokeAccessibleHover,
},
},

':hover .ms-Switch-track': {
[`:hover .${trackClassName}`]: {
':before': {
borderColor: theme.colorNeutralStrokeAccessibleHover,
},
},
}),

checked: theme => ({
':hover .ms-Switch-track': {
[`:hover .${trackClassName}`]: {
':after': {
background: theme.colorBrandBackgroundHover,
},
},

':active .ms-Switch-track': {
[`:active .${trackClassName}`]: {
':after': {
background: theme.colorBrandBackgroundPressed,
},
Expand Down Expand Up @@ -254,7 +254,7 @@ export const useSwitchStyles = (state: SwitchState): SwitchState => {
const inputStyles = useInputStyle();

state.root.className = mergeClasses(
rootClassName + (checked ? ' checked' : ''),
switchClassName + (checked ? ' checked' : ''),
rootStyles.root,
rootStyles.focusIndicator,
!disabled && rootStyles.checked,
Expand Down