Skip to content
Draft
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
Expand Up @@ -39,7 +39,8 @@ export type LinkContextValue = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-react-components/Charts-DonutChart 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic - RTL.default.chromium.png 5570 Changed
vr-tests-react-components/Menu Converged - submenuIndicator slotted content 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default.submenus open.chromium.png 413 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 736 Changed
vr-tests-react-components/Positioning.Positioning end.chromium.png 720 Changed
vr-tests-react-components/ProgressBar converged 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - Dark Mode.default.chromium.png 63 Changed
vr-tests-react-components/ProgressBar converged.Indeterminate + thickness.default.chromium.png 33 Changed

// @public (undocumented)
export type LinkProps = ComponentProps<LinkSlots> & {
appearance?: 'default' | 'subtle';
appearance?: 'default' | 'subtle' | 'inverted';
bold?: boolean;
disabled?: boolean;
disabledFocusable?: boolean;
inline?: boolean;
Expand All @@ -51,7 +52,7 @@ export type LinkSlots = {
};

// @public (undocumented)
export type LinkState = ComponentState<LinkSlots> & Required<Pick<LinkProps, 'appearance' | 'disabled' | 'disabledFocusable' | 'inline'>> & {
export type LinkState = ComponentState<LinkSlots> & Required<Pick<LinkProps, 'appearance' | 'bold' | 'disabled' | 'disabledFocusable' | 'inline'>> & {
backgroundAppearance?: BackgroundAppearanceContextValue;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ export type LinkProps = ComponentProps<LinkSlots> & {
* If not specified, the link appears with its default styling.
* @default 'default'
*/
appearance?: 'default' | 'subtle';
appearance?: 'default' | 'subtle' | 'inverted';

/**
* Whether the link should be bold.
* If set true, the link will be rendered with font weight 600 (tokens.fontWeightSemibold).
*
* @default false
*/
bold?: boolean;

/**
* Whether the link is disabled.
Expand Down Expand Up @@ -43,7 +51,7 @@ export type LinkProps = ComponentProps<LinkSlots> & {
export type LinkBaseProps = DistributiveOmit<LinkProps, 'appearance'>;

export type LinkState = ComponentState<LinkSlots> &
Required<Pick<LinkProps, 'appearance' | 'disabled' | 'disabledFocusable' | 'inline'>> & {
Required<Pick<LinkProps, 'appearance' | 'bold' | 'disabled' | 'disabledFocusable' | 'inline'>> & {
backgroundAppearance?: BackgroundAppearanceContextValue;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const useLinkBase_unstable = (
ref: React.Ref<HTMLAnchorElement | HTMLButtonElement | HTMLSpanElement>,
): LinkBaseState => {
const { inline: inlineContext } = useLinkContext();
const { disabled = false, disabledFocusable = false, inline = false } = props;
const { bold = false, disabled = false, disabledFocusable = false, inline = false } = props;

const elementType = props.as || (props.href ? 'a' : 'button');

Expand All @@ -54,6 +54,7 @@ export const useLinkBase_unstable = (

const state: LinkBaseState = {
// Props passed at the top-level
bold,
disabled,
disabledFocusable,
inline: inline ?? !!inlineContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,28 @@ const useStyles = makeStyles({
color: tokens.colorNeutralForegroundInvertedLinkPressed,
},
},
bold: {
fontWeight: tokens.fontWeightSemibold,
},
appearanceInverted: {
color: tokens.colorNeutralForegroundInvertedLink,
':hover': {
color: tokens.colorNeutralForegroundInvertedLinkHover,
},
':hover:active': {
color: tokens.colorNeutralForegroundInvertedLinkPressed,
},
':focus': {
textDecorationColor: tokens.colorNeutralForegroundInvertedLink,
},
},
});

export const useLinkStyles_unstable = (state: LinkState): LinkState => {
'use no memo';

const styles = useStyles();
const { appearance, disabled, inline, root, backgroundAppearance } = state;
const { appearance, bold, disabled, inline, root, backgroundAppearance } = state;

state.root.className = mergeClasses(
linkClassNames.root,
Expand All @@ -124,9 +139,11 @@ export const useLinkStyles_unstable = (state: LinkState): LinkState => {
root.as === 'a' && root.href && styles.href,
root.as === 'button' && styles.button,
appearance === 'subtle' && styles.subtle,
appearance === 'inverted' && styles.appearanceInverted,
backgroundAppearance === 'inverted' && styles.inverted,
backgroundAppearance === 'brand' && styles.brand,
inline && styles.inline,
bold && styles.bold,
disabled && styles.disabled,
state.root.className,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from 'react';
import type { JSXElement } from '@fluentui/react-components';
import { Link } from '@fluentui/react-components';

export const Bold = (): JSXElement => (
<Link bold href="https://www.bing.com">
Bold link
</Link>
);

Bold.parameters = {
docs: {
description: {
story: 'A link can be rendered with `bold` to apply a semibold font weight.',
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import type { JSXElement } from '@fluentui/react-components';
import { Link } from '@fluentui/react-components';

export const Inverted = (): JSXElement => (
<div style={{ backgroundColor: '#333', padding: '16px' }}>
<Link appearance="inverted" href="https://www.bing.com">
Inverted link
</Link>
</div>
);

Inverted.parameters = {
docs: {
description: {
story:
'A link can use `appearance="inverted"` to be styled for dark backgrounds, ' +
'using inverted foreground link tokens for default, hover, and pressed states.',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import accessibilityMd from './LinkAccessibility.md';

export { Default } from './LinkDefault.stories';
export { Appearance } from './LinkAppearance.stories';
export { Inverted } from './LinkInverted.stories';
export { Bold } from './LinkBold.stories';
export { Inline } from './LinkInline.stories';
export { Disabled } from './LinkDisabled.stories';
export { DisabledFocusable } from './LinkDisabledFocusable.stories';
Expand Down
Loading