Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-link: Replacing use of functions in makeStyles with direct use of tokens #21047

Merged
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": "prerelease",
"comment": "react-link: Replacing use of functions in makeStyles with direct use of tokens.",
"packageName": "@fluentui/react-link",
"email": "[email protected]",
"dependentChangeType": "patch"
}
60 changes: 31 additions & 29 deletions packages/react-link/src/components/Link/useLinkStyles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as React from 'react';
import { shorthands, makeStyles, mergeClasses } from '@fluentui/react-make-styles';
import { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';
import { tokens } from '@fluentui/react-theme';
import type { LinkState } from './Link.types';

export const linkClassName = 'fui-Link';
Expand All @@ -10,21 +12,21 @@ const useStyles = makeStyles({
textDecorationStyle: 'double',
}),
// Common styles.
root: theme => ({
root: {
backgroundColor: 'transparent',
borderTopStyle: 'none',
borderLeftStyle: 'none',
borderRightStyle: 'none',
borderBottomColor: 'transparent',
borderBottomStyle: 'solid',
borderBottomWidth: theme.strokeWidthThin,
borderBottomWidth: tokens.strokeWidthThin,
boxSizing: 'border-box',
color: theme.colorBrandForegroundLink,
color: tokens.colorBrandForegroundLink,
cursor: 'pointer',
display: 'inline',
fontFamily: theme.fontFamilyBase,
fontSize: theme.fontSizeBase300,
fontWeight: theme.fontWeightRegular,
fontFamily: tokens.fontFamilyBase,
fontSize: tokens.fontSizeBase300,
fontWeight: tokens.fontWeightRegular as React.CSSProperties['fontWeight'],
...shorthands.margin(0),
...shorthands.padding(0),
...shorthands.overflow('inherit'),
Expand All @@ -34,57 +36,57 @@ const useStyles = makeStyles({
userSelect: 'text',

':hover': {
borderBottomColor: theme.colorBrandForegroundLinkHover,
color: theme.colorBrandForegroundLinkHover,
borderBottomColor: tokens.colorBrandForegroundLinkHover,
color: tokens.colorBrandForegroundLinkHover,
},

':active': {
borderBottomColor: theme.colorBrandForegroundLinkPressed,
color: theme.colorBrandForegroundLinkPressed,
borderBottomColor: tokens.colorBrandForegroundLinkPressed,
color: tokens.colorBrandForegroundLinkPressed,
},
}),
},
// Overrides when an href is present so the Link renders as an anchor.
href: {
fontSize: 'inherit',
},
// Overrides when the Link appears subtle.
subtle: theme => ({
color: theme.colorNeutralForeground2,
subtle: {
color: tokens.colorNeutralForeground2,

':hover': {
borderBottomColor: theme.colorNeutralForeground2Hover,
color: theme.colorNeutralForeground2Hover,
borderBottomColor: tokens.colorNeutralForeground2Hover,
color: tokens.colorNeutralForeground2Hover,
},

':active': {
borderBottomColor: theme.colorNeutralForeground2Pressed,
color: theme.colorNeutralForeground2Pressed,
borderBottomColor: tokens.colorNeutralForeground2Pressed,
color: tokens.colorNeutralForeground2Pressed,
},
}),
},
// Overrides when the Link is rendered inline within text.
inline: theme => ({
borderBottomColor: theme.colorBrandForegroundLink,
}),
inline: {
borderBottomColor: tokens.colorBrandForegroundLink,
},
// Overrides when the Link is rendered inline within text and appears subtle.
inlineSubtle: theme => ({
borderBottomColor: theme.colorNeutralForeground2,
}),
inlineSubtle: {
borderBottomColor: tokens.colorNeutralForeground2,
},
// Overrides when the Link is disabled.
disabled: theme => ({
disabled: {
borderBottomColor: 'transparent',
color: theme.colorNeutralForegroundDisabled,
color: tokens.colorNeutralForegroundDisabled,
cursor: 'not-allowed',

':hover': {
borderBottomColor: 'transparent',
color: theme.colorNeutralForegroundDisabled,
color: tokens.colorNeutralForegroundDisabled,
},

':active': {
borderBottomColor: 'transparent',
color: theme.colorNeutralForegroundDisabled,
color: tokens.colorNeutralForegroundDisabled,
},
}),
},
});

export const useLinkStyles = (state: LinkState): LinkState => {
Expand Down