Skip to content

Commit

Permalink
react-link: Replacing use of functions in makeStyles with direct use …
Browse files Browse the repository at this point in the history
…of tokens (#21047)

#### Pull request checklist

- [x] Addresses an existing issue: Implements part of #20651
- [x] Include a change request file using `$ yarn change`

#### Description of changes

_This PR is part of a series of PRs that split #20918 into smaller PRs._
_This PR follows #21026._

This PR replaces the use of functions in `makeStyles` calls in the `@fluentui/react-link` package with direct use of the `tokens` exported from `@fluentui/react-theme`.
  • Loading branch information
khmakoto authored Jan 6, 2022
1 parent 147ca59 commit e92670a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
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

0 comments on commit e92670a

Please sign in to comment.