Skip to content

Commit

Permalink
fix(Link, Button): add theme variables for border-bottom (#3203)
Browse files Browse the repository at this point in the history
  • Loading branch information
HelenaIsh committed Jul 17, 2023
1 parent de54cba commit d418758
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
2 changes: 2 additions & 0 deletions packages/react-ui/components/Button/getInnerLinkTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const getInnerLinkTheme = (theme: Theme): Theme => {
return ThemeFactory.create(
{
linkLineBorderBottomStyle: theme.btnLinkLineBorderBottomStyle,
linkLineHoverBorderBottomStyle: theme.btnLinkHoverLineBorderBottomStyle,
linkLineBorderBottomOpacity: theme.btnLinkLineBorderBottomOpacity,
linkLineBorderBottomWidth: theme.btnLinkLineBorderBottomWidth,
linkDisabledColor: theme.btnLinkDisabledColor,
},
Expand Down
3 changes: 2 additions & 1 deletion packages/react-ui/components/Link/Link.mixins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ export const linkUseColorsMixin = (mainColor: string, hoverColor: string, active
`;
};

export const linkUseLineWithoutOpacity = () => {
export const linkUseLineHovered = (linkLineHoverBorderBottomStyle: string) => {
return `
animation: none !important;
border-bottom-style: ${linkLineHoverBorderBottomStyle};
`;
};
26 changes: 14 additions & 12 deletions packages/react-ui/components/Link/Link.styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css, keyframes, memoizeStyle, prefix } from '../../lib/theming/Emotion';
import { Theme } from '../../lib/theming/Theme';

import { linkMixin, linkDisabledMixin, linkUseColorsMixin, linkUseLineWithoutOpacity } from './Link.mixins';
import { linkMixin, linkDisabledMixin, linkUseColorsMixin, linkUseLineHovered } from './Link.mixins';

export const globalClasses = prefix('link')({
text: 'text',
Expand Down Expand Up @@ -33,20 +33,22 @@ export const styles = memoizeStyle({
},

lineText(t: Theme) {
const delay = parseFloat(t.linkLineBorderBottomOpacity) - 1;
return css`
border-bottom-style: ${t.linkLineBorderBottomStyle};
border-bottom-width: ${t.linkLineBorderBottomWidth};
animation: ${line} 1s linear !important; // override creevey
animation-play-state: paused !important;
animation-delay: -0.5s !important;
animation-delay: ${delay}s !important;
animation-fill-mode: forwards !important;
`;
},

lineFocus(t: Theme) {
return css`
color: ${t.linkHoverColor};
.${globalClasses.text} {
${linkUseLineWithoutOpacity()}
${linkUseLineHovered(t.linkLineHoverBorderBottomStyle)}
}
`;
},
Expand All @@ -55,7 +57,7 @@ export const styles = memoizeStyle({
return css`
color: ${t.linkSuccessHoverColor} !important;
.${globalClasses.text} {
${linkUseLineWithoutOpacity()}
${linkUseLineHovered(t.linkLineHoverBorderBottomStyle)}
}
`;
},
Expand All @@ -64,7 +66,7 @@ export const styles = memoizeStyle({
return css`
color: ${t.linkDangerHoverColor} !important;
.${globalClasses.text} {
${linkUseLineWithoutOpacity()}
${linkUseLineHovered(t.linkLineHoverBorderBottomStyle)}
}
`;
},
Expand All @@ -73,7 +75,7 @@ export const styles = memoizeStyle({
return css`
color: ${t.linkGrayedHoverColor} !important;
.${globalClasses.text} {
${linkUseLineWithoutOpacity()}
${linkUseLineHovered(t.linkLineHoverBorderBottomStyle)}
}
`;
},
Expand Down Expand Up @@ -115,7 +117,7 @@ export const styles = memoizeStyle({
${linkUseColorsMixin(t.linkColor, t.linkHoverColor, t.linkActiveColor)};
.${globalClasses.text} {
:hover {
${linkUseLineWithoutOpacity()}
${linkUseLineHovered(t.linkLineHoverBorderBottomStyle)}
}
}
`;
Expand All @@ -126,7 +128,7 @@ export const styles = memoizeStyle({
${linkUseColorsMixin(t.linkSuccessColor, t.linkSuccessHoverColor, t.linkSuccessActiveColor)};
.${globalClasses.text} {
:hover {
${linkUseLineWithoutOpacity()}
${linkUseLineHovered(t.linkLineHoverBorderBottomStyle)}
}
}
`;
Expand All @@ -137,7 +139,7 @@ export const styles = memoizeStyle({
${linkUseColorsMixin(t.linkDangerColor, t.linkDangerHoverColor, t.linkDangerActiveColor)};
.${globalClasses.text} {
:hover {
${linkUseLineWithoutOpacity()}
${linkUseLineHovered(t.linkLineHoverBorderBottomStyle)}
}
}
`;
Expand All @@ -148,7 +150,7 @@ export const styles = memoizeStyle({
${linkUseColorsMixin(t.linkGrayedColor, t.linkGrayedHoverColor, t.linkGrayedActiveColor)};
.${globalClasses.text} {
:hover {
${linkUseLineWithoutOpacity()}
${linkUseLineHovered(t.linkLineHoverBorderBottomStyle)}
}
}
`;
Expand Down Expand Up @@ -178,10 +180,10 @@ export const styles = memoizeStyle({
`;
},

disabledDark22Theme() {
disabledDark22Theme(t: Theme) {
return css`
.${globalClasses.text} {
${linkUseLineWithoutOpacity()}
${linkUseLineHovered(t.linkLineHoverBorderBottomStyle)}
}
`;
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export class Link extends React.Component<LinkProps, LinkState> {
: cx(
styles.lineRoot(),
disabled && styles.disabled(this.theme),
disabled && _isTheme2022 && isDarkTheme(this.theme) && styles.disabledDark22Theme(),
disabled && _isTheme2022 && isDarkTheme(this.theme) && styles.disabledDark22Theme(this.theme),
isFocused && use === 'default' && styles.lineFocus(this.theme),
isFocused && use === 'success' && styles.lineFocusSuccess(this.theme),
isFocused && use === 'danger' && styles.lineFocusDanger(this.theme),
Expand Down
10 changes: 10 additions & 0 deletions packages/react-ui/internal/themes/DefaultTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ export class DefaultTheme {
public static linkButtonPaddingX = '10px';

public static linkLineBorderBottomStyle = '';
public static get linkLineHoverBorderBottomStyle() {
return this.linkLineBorderBottomStyle;
}
public static linkLineBorderBottomWidth = '0px';
public static linkLineBorderBottomOpacity = '0.5';

//#endregion
//#region Token
Expand Down Expand Up @@ -484,7 +488,13 @@ export class DefaultTheme {
return this.linkHoverTextDecoration;
}
public static btnLinkLineBorderBottomStyle = '';
public static get btnLinkHoverLineBorderBottomStyle() {
return this.btnLinkLineBorderBottomStyle;
}
public static btnLinkLineBorderBottomWidth = '0px';
public static get btnLinkLineBorderBottomOpacity() {
return this.linkLineBorderBottomOpacity;
}

public static get btnLinkIconMarginRight() {
return this.linkIconMarginRight;
Expand Down

0 comments on commit d418758

Please sign in to comment.