-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react-button): apply hover only on devices that support hover
- Loading branch information
1 parent
a9fdb46
commit 81628a4
Showing
15 changed files
with
367 additions
and
243 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/react-components/react-button/library/src/components/Button/Button.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
File renamed without changes.
67 changes: 2 additions & 65 deletions
67
...ages/react-components/react-button/library/src/components/Button/useButtonStyles/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 |
---|---|---|
@@ -1,65 +1,2 @@ | ||
import { mergeClasses } from '@griffel/react'; | ||
import type { ButtonState } from '../Button.types'; | ||
import { buttonClassNames } from './consts'; | ||
import { useRootBaseClassName } from './useRootBaseClassName.styles'; | ||
import { useIconBaseClassName } from './useIconBaseClassName.styles'; | ||
import { useRootStyles } from './useRootStyles.styles'; | ||
import { useRootDisabledStyles } from './useRootDisabledStyles.styles'; | ||
import { useRootFocusStyles } from './useRootFocusStyles.styles'; | ||
import { useRootIconOnlyStyles } from './useRootIconOnlyStates.styles'; | ||
import { useIconStyles } from './useIconStyles.styles'; | ||
|
||
export const useButtonStyles_unstable = (state: ButtonState): ButtonState => { | ||
const rootBaseClassName = useRootBaseClassName(); | ||
const iconBaseClassName = useIconBaseClassName(); | ||
|
||
const rootStyles = useRootStyles(); | ||
const rootDisabledStyles = useRootDisabledStyles(); | ||
const rootFocusStyles = useRootFocusStyles(); | ||
const rootIconOnlyStyles = useRootIconOnlyStyles(); | ||
const iconStyles = useIconStyles(); | ||
|
||
const { appearance, disabled, disabledFocusable, icon, iconOnly, iconPosition, shape, size } = state; | ||
|
||
state.root.className = mergeClasses( | ||
buttonClassNames.root, | ||
rootBaseClassName, | ||
|
||
appearance && rootStyles[appearance], | ||
|
||
rootStyles[size], | ||
icon && size === 'small' && rootStyles.smallWithIcon, | ||
icon && size === 'large' && rootStyles.largeWithIcon, | ||
rootStyles[shape], | ||
|
||
// Disabled styles | ||
(disabled || disabledFocusable) && rootDisabledStyles.base, | ||
(disabled || disabledFocusable) && rootDisabledStyles.highContrast, | ||
appearance && (disabled || disabledFocusable) && rootDisabledStyles[appearance], | ||
|
||
// Focus styles | ||
appearance === 'primary' && rootFocusStyles.primary, | ||
rootFocusStyles[size], | ||
rootFocusStyles[shape], | ||
|
||
// Icon-only styles | ||
iconOnly && rootIconOnlyStyles[size], | ||
|
||
// User provided class name | ||
state.root.className, | ||
); | ||
|
||
if (state.icon) { | ||
state.icon.className = mergeClasses( | ||
buttonClassNames.icon, | ||
iconBaseClassName, | ||
!!state.root.children && iconStyles[iconPosition], | ||
iconStyles[size], | ||
state.icon.className, | ||
); | ||
} | ||
|
||
return state; | ||
}; | ||
|
||
export { buttonClassNames }; | ||
export { useButtonStyles_unstable } from './useButtonStyles.styles'; | ||
export { buttonClassNames } from './constants'; |
63 changes: 63 additions & 0 deletions
63
...ents/react-button/library/src/components/Button/useButtonStyles/useButtonStyles.styles.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,63 @@ | ||
import { mergeClasses } from '@griffel/react'; | ||
import type { ButtonState } from '../Button.types'; | ||
import { buttonClassNames } from './constants'; | ||
import { useRootBaseClassName } from './useRootBaseClassName.styles'; | ||
import { useIconBaseClassName } from './useIconBaseClassName.styles'; | ||
import { useRootStyles } from './useRootStyles.styles'; | ||
import { useRootDisabledStyles } from './useRootDisabledStyles.styles'; | ||
import { useRootFocusStyles } from './useRootFocusStyles.styles'; | ||
import { useRootIconOnlyStyles } from './useRootIconOnlyStates.styles'; | ||
import { useIconStyles } from './useIconStyles.styles'; | ||
|
||
export const useButtonStyles_unstable = (state: ButtonState): ButtonState => { | ||
const rootBaseClassName = useRootBaseClassName(); | ||
const iconBaseClassName = useIconBaseClassName(); | ||
|
||
const rootStyles = useRootStyles(); | ||
const rootDisabledStyles = useRootDisabledStyles(); | ||
const rootFocusStyles = useRootFocusStyles(); | ||
const rootIconOnlyStyles = useRootIconOnlyStyles(); | ||
const iconStyles = useIconStyles(); | ||
|
||
const { appearance, disabled, disabledFocusable, icon, iconOnly, iconPosition, shape, size } = state; | ||
|
||
state.root.className = mergeClasses( | ||
buttonClassNames.root, | ||
rootBaseClassName, | ||
|
||
appearance && rootStyles[appearance], | ||
|
||
rootStyles[size], | ||
icon && size === 'small' && rootStyles.smallWithIcon, | ||
icon && size === 'large' && rootStyles.largeWithIcon, | ||
rootStyles[shape], | ||
|
||
// Disabled styles | ||
(disabled || disabledFocusable) && rootDisabledStyles.base, | ||
(disabled || disabledFocusable) && rootDisabledStyles.highContrast, | ||
appearance && (disabled || disabledFocusable) && rootDisabledStyles[appearance], | ||
|
||
// Focus styles | ||
appearance === 'primary' && rootFocusStyles.primary, | ||
rootFocusStyles[size], | ||
rootFocusStyles[shape], | ||
|
||
// Icon-only styles | ||
iconOnly && rootIconOnlyStyles[size], | ||
|
||
// User provided class name | ||
state.root.className, | ||
); | ||
|
||
if (state.icon) { | ||
state.icon.className = mergeClasses( | ||
buttonClassNames.icon, | ||
iconBaseClassName, | ||
!!state.root.children && iconStyles[iconPosition], | ||
iconStyles[size], | ||
state.icon.className, | ||
); | ||
} | ||
|
||
return state; | ||
}; |
2 changes: 1 addition & 1 deletion
2
...react-button/library/src/components/Button/useButtonStyles/useIconBaseClassName.styles.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
2 changes: 1 addition & 1 deletion
2
...onents/react-button/library/src/components/Button/useButtonStyles/useIconStyles.styles.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
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
2 changes: 1 addition & 1 deletion
2
...eact-button/library/src/components/Button/useButtonStyles/useRootIconOnlyStates.styles.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
Oops, something went wrong.