Skip to content
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
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import type { Meta } from '@storybook/react';
Comment thread
mainframev marked this conversation as resolved.
import { Link, LinkProps } from '@fluentui/react-link';

import { InvertedBackground, steps } from './utils';
import { InvertedBackground, BrandBackground, steps } from './utils';
import { DARK_MODE, getStoryVariant, HIGH_CONTRAST, RTL } from '../../utilities';
import type { StoryParameters } from 'storywright';

Expand Down Expand Up @@ -70,6 +70,15 @@ export const InvertedDisabled = () => (
);
InvertedDisabled.storyName = 'Inverted disabled';

export const Brand = () => (
<BrandBackground>
<AnchorLink>Link on brand background</AnchorLink>
</BrandBackground>
);

export const BrandDarkMode = getStoryVariant(Brand, DARK_MODE);
export const BrandHighContrast = getStoryVariant(Brand, HIGH_CONTRAST);

export const InvertedDisabledHighContrast = getStoryVariant(InvertedDisabled, HIGH_CONTRAST);

export const InvertedDisabledDarkMode = getStoryVariant(InvertedDisabled, DARK_MODE);
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import type { Meta } from '@storybook/react';
import { Link, LinkProps } from '@fluentui/react-link';

import { InvertedBackground, steps } from './utils';
import { InvertedBackground, BrandBackground, steps } from './utils';
import { DARK_MODE, getStoryVariant, HIGH_CONTRAST, RTL } from '../../utilities';
import type { StoryParameters } from 'storywright';

Expand Down Expand Up @@ -63,6 +63,15 @@ export const InvertedDisabled = () => (
);
InvertedDisabled.storyName = 'Inverted disabled';

export const Brand = () => (
<BrandBackground>
<ButtonLink>Link on brand background</ButtonLink>
</BrandBackground>
);

export const BrandDarkMode = getStoryVariant(Brand, DARK_MODE);
export const BrandHighContrast = getStoryVariant(Brand, HIGH_CONTRAST);

export const InvertedDisabledHighContrast = getStoryVariant(InvertedDisabled, HIGH_CONTRAST);

export const InvertedDisabledDarkMode = getStoryVariant(InvertedDisabled, DARK_MODE);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import type { Meta } from '@storybook/react';
import { Link, LinkProps } from '@fluentui/react-link';

import { InvertedBackground, steps } from './utils';
import { InvertedBackground, BrandBackground, steps } from './utils';
import { DARK_MODE, getStoryVariant, HIGH_CONTRAST, RTL } from '../../utilities';
import type { StoryParameters } from 'storywright';

Expand Down Expand Up @@ -42,7 +42,6 @@ export const InlineDisabledFocusable = () => (
used alongside other text content.
</div>
);

export const Inverted = () => (
<InvertedBackground>
<SpanLink>Link on inverted background</SpanLink>
Expand Down Expand Up @@ -72,4 +71,14 @@ export const WrapsCorrectlyAsAnInlineElement = () => (
expected.
</div>
);

export const Brand = () => (
<BrandBackground>
<SpanLink>Link on brand background</SpanLink>
</BrandBackground>
);

export const BrandDarkMode = getStoryVariant(Brand, DARK_MODE);
export const BrandHighContrast = getStoryVariant(Brand, HIGH_CONTRAST);

WrapsCorrectlyAsAnInlineElement.storyName = 'Wraps correctly as an inline element';
16 changes: 16 additions & 0 deletions apps/vr-tests-react-components/src/stories/Link/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ const useInvertedBackgroundStyles = makeStyles({
},
});

const useBrandBackgroundStyles = makeStyles({
root: {
...shorthands.padding('14px'),
backgroundColor: tokens.colorBrandBackgroundStatic,
},
});

export const InvertedBackground: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const styles = useInvertedBackgroundStyles();
return (
Expand All @@ -20,6 +27,15 @@ export const InvertedBackground: React.FC<{ children: React.ReactNode }> = ({ ch
);
};

export const BrandBackground: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const styles = useBrandBackgroundStyles();
return (
<div className={styles.root}>
<BackgroundAppearanceProvider value="brand">{children}</BackgroundAppearanceProvider>
</div>
);
};

export const steps = new Steps()
.snapshot('default')
.hover('.fui-Link')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: add brand appearance variant",
"packageName": "@fluentui/react-link",
"email": "vgenaev@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: add brand appearance variant for background context",
"packageName": "@fluentui/react-shared-contexts",
"email": "vgenaev@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,16 @@ const useStyles = makeStyles({
color: tokens.colorNeutralForegroundDisabled,
},
},

inverted: {
color: tokens.colorNeutralForegroundInverted2,
Comment thread
mainframev marked this conversation as resolved.
':hover': {
color: tokens.colorNeutralForegroundInverted2,
},
':active': {
color: tokens.colorNeutralForegroundInverted2,
},
},
brand: {
color: tokens.colorNeutralForegroundInvertedLink,
':hover': {
color: tokens.colorNeutralForegroundInvertedLinkHover,
Expand All @@ -117,6 +125,7 @@ export const useLinkStyles_unstable = (state: LinkState): LinkState => {
root.as === 'button' && styles.button,
appearance === 'subtle' && styles.subtle,
backgroundAppearance === 'inverted' && styles.inverted,
backgroundAppearance === 'brand' && styles.brand,
inline && styles.inline,
disabled && styles.disabled,
state.root.className,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export { AnnounceProvider }
export { AnnounceProvider as AnnounceProvider_unstable }

// @internal (undocumented)
export type BackgroundAppearanceContextValue = 'inverted' | undefined;
export type BackgroundAppearanceContextValue = 'inverted' | 'brand' | undefined;

// @internal (undocumented)
export const BackgroundAppearanceProvider: React_2.Provider<BackgroundAppearanceContextValue>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as React from 'react';
/**
* @internal
*/
export type BackgroundAppearanceContextValue = 'inverted' | undefined;
export type BackgroundAppearanceContextValue = 'inverted' | 'brand' | undefined;

/**
* @internal
Expand Down