Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9a3985d
Raw double implementation for testing
Jun 30, 2021
e37e97c
Remove alternative implementation
Jul 2, 2021
8bd9d24
Ammend spec
Jul 2, 2021
e2bcf19
Move typographyStyles to root folder
Jul 2, 2021
d210fff
Fix imports
Jul 2, 2021
c9cbeb1
Add docs for typographyStyles
Jul 2, 2021
bc2106c
Merge branch 'master' into typography-hook-implementation
Jul 2, 2021
160dc1d
Text implementation (#18590)
Jul 2, 2021
0e39040
Simplify prop merging with slots (#18721)
bsunderhus Jul 2, 2021
095feba
Add Display wrapper component
Jul 2, 2021
d1c1931
Merge branch 'master' into text-wrappers
Jul 2, 2021
3023c7b
Undo formatting
Jul 2, 2021
1ee3883
Separate typographyStyles into multiple exports
Jul 9, 2021
4cf68ec
Use hooks approach for wrapper
Jul 9, 2021
dcc054a
Merge branch 'master' into typography-hook-implementation
Jul 9, 2021
76ca9bd
Fix test import
Jul 9, 2021
75755f2
Implement temporary alternative until #18906 is fixed
Jul 12, 2021
1cb1549
Merge branch 'master' into typography-hook-implementation
Jul 15, 2021
e0220ee
Update API
Jul 15, 2021
9e4e616
Cleanup test
Jul 15, 2021
4f98d8d
Merge branch 'typography-hook-implementation' into text-wrappers
Jul 15, 2021
a84d61f
Add LargeTitle wrapper
Jul 15, 2021
0cd0a13
Add Title1 wrapper
Jul 15, 2021
08b8d79
Add Title2 wrapper
Jul 15, 2021
e069ea6
Add Title3 wrapper
Jul 15, 2021
bc77315
Add Headline wrapper
Jul 15, 2021
4ebac67
Add Subheadline wrapper
Jul 15, 2021
f9de72a
Add Body wrapper
Jul 15, 2021
55d5d5e
Add Caption wrapper
Jul 15, 2021
b07dcc5
Update API
Jul 15, 2021
cda24b6
Add bundle-size fixtures
Jul 15, 2021
4ab2aba
Merge branch 'master' into text-wrappers-remaining
Jul 15, 2021
278d19b
Update API
Jul 15, 2021
618b63c
Add missing imports for stories
Jul 15, 2021
7494f86
Changed to the createWrapper approach
tringakrasniqi Jul 20, 2021
7ece1f8
Removed unnecessary displayname for Title3
tringakrasniqi Jul 20, 2021
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
7 changes: 7 additions & 0 deletions packages/react-text/bundle-size/Text.Default.fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Text } from '@fluentui/react-text';

console.log(Text);

export default {
name: 'Text - Default',
};
17 changes: 17 additions & 0 deletions packages/react-text/bundle-size/Text.Wrappers.fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {
Display,
LargeTitle,
Title1,
Title2,
Title3,
Headline,
Subheadline,
Body,
Caption,
} from '@fluentui/react-text';

console.log(Display, LargeTitle, Title1, Title2, Title3, Headline, Subheadline, Body, Caption);

export default {
name: 'Text - Wrappers',
};
31 changes: 28 additions & 3 deletions packages/react-text/etc/react-text.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,51 @@

import { ComponentPropsCompat } from '@fluentui/react-utilities';
import { ComponentStateCompat } from '@fluentui/react-utilities';
import { ForwardRefExoticComponent } from 'react';
import { MakeStylesStyleFunctionRule } from '@fluentui/make-styles';
import * as React_2 from 'react';
import { RefAttributes } from 'react';
import { Theme } from '@fluentui/react-theme';

// @public (undocumented)
const body: MakeStylesStyleFunctionRule<Theme>;

// Warning: (ae-forgotten-export) The symbol "Props" needs to be exported by the entry point index.d.ts
//
// @public
const Body_2: ForwardRefExoticComponent<Props & RefAttributes<HTMLElement>>;
export { Body_2 as Body }

// @public
export const Caption: ForwardRefExoticComponent<Props & RefAttributes<HTMLElement>>;

// @public
const caption: MakeStylesStyleFunctionRule<Theme>;

// @public
export const Display: React_2.ForwardRefExoticComponent<DisplayProps & React_2.RefAttributes<HTMLElement>>;
export const Display: ForwardRefExoticComponent<Props & RefAttributes<HTMLElement>>;

// @public (undocumented)
const display: MakeStylesStyleFunctionRule<Theme>;

// @public
export interface DisplayProps extends Omit<TextProps, 'font' | 'size'> {
}
export const Headline: ForwardRefExoticComponent<Props & RefAttributes<HTMLElement>>;

// @public (undocumented)
const headline: MakeStylesStyleFunctionRule<Theme>;

// @public
export const LargeTitle: ForwardRefExoticComponent<Props & RefAttributes<HTMLElement>>;

// @public (undocumented)
const largeTitle: MakeStylesStyleFunctionRule<Theme>;

// @public
export const renderText: (state: TextState) => JSX.Element;

// @public
export const Subheadline: ForwardRefExoticComponent<Props & RefAttributes<HTMLElement>>;

// @public (undocumented)
const subheadline: MakeStylesStyleFunctionRule<Theme>;

Expand Down Expand Up @@ -65,12 +81,21 @@ export interface TextState extends ComponentStateCompat<TextProps, TextDefaulted
ref: React_2.Ref<HTMLElement>;
}

// @public
export const Title1: ForwardRefExoticComponent<Props & RefAttributes<HTMLElement>>;

// @public (undocumented)
const title1: MakeStylesStyleFunctionRule<Theme>;

// @public
export const Title2: ForwardRefExoticComponent<Props & RefAttributes<HTMLElement>>;

// @public (undocumented)
const title2: MakeStylesStyleFunctionRule<Theme>;

// @public
export const Title3: ForwardRefExoticComponent<Props & RefAttributes<HTMLElement>>;

// @public (undocumented)
const title3: MakeStylesStyleFunctionRule<Theme>;

Expand Down
1 change: 1 addition & 0 deletions packages/react-text/src/Body.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Body/index';
1 change: 1 addition & 0 deletions packages/react-text/src/Caption.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Caption/index';
1 change: 1 addition & 0 deletions packages/react-text/src/Headline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Headline/index';
1 change: 1 addition & 0 deletions packages/react-text/src/LargeTitle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/LargeTitle/index';
1 change: 1 addition & 0 deletions packages/react-text/src/Subheadline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Subheadline/index';
10 changes: 9 additions & 1 deletion packages/react-text/src/TextWrappers.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { Display } from './components/Display';
import { Display, LargeTitle, Title1, Title2, Title3, Headline, Subheadline, Body, Caption } from './index';
import { FluentProvider } from '@fluentui/react-provider';
import { webLightTheme } from '@fluentui/react-theme';

<Meta title="Components/Text/Wrappers" />

<FluentProvider theme={webLightTheme}>
<Display block>Display text wrapper, semibold, base1000</Display>
<LargeTitle block>LargeTitle text wrapper, semibold, base900</LargeTitle>
<Title1 block>Title1 text wrapper, semibold, base800</Title1>
<Title2 block>Title2 text wrapper, semibold, base700</Title2>
<Title3 block>Title3 text wrapper, semibold, base600</Title3>
<Headline block>Headline text wrapper, semibold, base500</Headline>
<Subheadline block>Subheadline text wrapper, semibold, base400</Subheadline>
<Body block>Body text wrapper, regular, base300</Body>
<Caption block>Caption text wrapper, regular, base200</Caption>
</FluentProvider>
1 change: 1 addition & 0 deletions packages/react-text/src/Title1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Title1/index';
1 change: 1 addition & 0 deletions packages/react-text/src/Title2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Title2/index';
1 change: 1 addition & 0 deletions packages/react-text/src/Title3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Title3/index';
16 changes: 16 additions & 0 deletions packages/react-text/src/components/Body/Body.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from 'react';
import { render } from '@testing-library/react';
import { Body } from './Body';
import { isConformant } from '../../common/isConformant';

describe('Body', () => {
isConformant({
Component: Body,
displayName: 'Body',
});

it('renders a default state', () => {
const result = render(<Body>Default Body</Body>);
expect(result.container).toMatchSnapshot();
});
});
15 changes: 15 additions & 0 deletions packages/react-text/src/components/Body/Body.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { makeStyles } from '@fluentui/react-make-styles';
import { typographyStyles } from '../../index';
import { createWrapper } from '../wrapper';

/**
* Styles for the root slot
*/
const useStyles = makeStyles({
root: typographyStyles.body,
});

/**
* Text wrapper component for the Body typography variant
*/
export const Body = createWrapper({ useStyles, displayName: 'Body' });
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Body renders a default state 1`] = `
<div>
<span
class=""
>
Default Body
</span>
</div>
`;
1 change: 1 addition & 0 deletions packages/react-text/src/components/Body/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Body';
16 changes: 16 additions & 0 deletions packages/react-text/src/components/Caption/Caption.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from 'react';
import { render } from '@testing-library/react';
import { Caption } from './Caption';
import { isConformant } from '../../common/isConformant';

describe('Caption', () => {
isConformant({
Component: Caption,
displayName: 'Caption',
});

it('renders a default state', () => {
const result = render(<Caption>Default Caption</Caption>);
expect(result.container).toMatchSnapshot();
});
});
15 changes: 15 additions & 0 deletions packages/react-text/src/components/Caption/Caption.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { makeStyles } from '@fluentui/react-make-styles';
import { typographyStyles } from '../../index';
import { createWrapper } from '../wrapper';

/**
* Styles for the root slot
*/
const useStyles = makeStyles({
root: typographyStyles.caption,
});

/**
* Text wrapper component for the Caption typography variant
*/
export const Caption = createWrapper({ useStyles, displayName: 'Caption' });
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Caption renders a default state 1`] = `
<div>
<span
class=""
>
Default Caption
</span>
</div>
`;
1 change: 1 addition & 0 deletions packages/react-text/src/components/Caption/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Caption';
18 changes: 3 additions & 15 deletions packages/react-text/src/components/Display/Display.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as React from 'react';
import { makeStyles, mergeClasses } from '@fluentui/react-make-styles';
import { renderText, useText, useTextStyles } from '../Text/index';
import { makeStyles } from '@fluentui/react-make-styles';
import { typographyStyles } from '../../typographyStyles/index';
import { DisplayProps } from './Display.types';
import { createWrapper } from '../wrapper';

/**
* Styles for the root slot
Expand All @@ -14,14 +12,4 @@ const useStyles = makeStyles({
/**
* Text wrapper component for the Display typography variant
*/
export const Display = React.forwardRef<HTMLElement, DisplayProps>((props, ref) => {
const styles = useStyles();
const state = useText(props, ref);
useTextStyles(state);

state.className = mergeClasses(state.className, styles.root, props.className);

return renderText(state);
});

Display.displayName = 'Display';
export const Display = createWrapper({ useStyles, displayName: 'Display' });
6 changes: 0 additions & 6 deletions packages/react-text/src/components/Display/Display.types.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/react-text/src/components/Display/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './Display';
export * from './Display.types';
16 changes: 16 additions & 0 deletions packages/react-text/src/components/Headline/Headline.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from 'react';
import { render } from '@testing-library/react';
import { Headline } from './Headline';
import { isConformant } from '../../common/isConformant';

describe('Headline', () => {
isConformant({
Component: Headline,
displayName: 'Headline',
});

it('renders a default state', () => {
const result = render(<Headline>Default Headline</Headline>);
expect(result.container).toMatchSnapshot();
});
});
15 changes: 15 additions & 0 deletions packages/react-text/src/components/Headline/Headline.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { makeStyles } from '@fluentui/react-make-styles';
import { typographyStyles } from '../../index';
import { createWrapper } from '../wrapper';

/**
* Styles for the root slot
*/
const useStyles = makeStyles({
root: typographyStyles.headline,
});

/**
* Text wrapper component for the Headline typography variant
*/
export const Headline = createWrapper({ useStyles, displayName: 'Headline' });
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Headline renders a default state 1`] = `
<div>
<span
class=""
>
Default Headline
</span>
</div>
`;
1 change: 1 addition & 0 deletions packages/react-text/src/components/Headline/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Headline';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from 'react';
import { render } from '@testing-library/react';
import { LargeTitle } from './LargeTitle';
import { isConformant } from '../../common/isConformant';

describe('LargeTitle', () => {
isConformant({
Component: LargeTitle,
displayName: 'LargeTitle',
});

it('renders a default state', () => {
const result = render(<LargeTitle>Default LargeTitle</LargeTitle>);
expect(result.container).toMatchSnapshot();
});
});
15 changes: 15 additions & 0 deletions packages/react-text/src/components/LargeTitle/LargeTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { makeStyles } from '@fluentui/react-make-styles';
import { typographyStyles } from '../../index';
import { createWrapper } from '../wrapper';

/**
* Styles for the root slot
*/
const useStyles = makeStyles({
root: typographyStyles.largeTitle,
});

/**
* Text wrapper component for the Large Title typography variant
*/
export const LargeTitle = createWrapper({ useStyles, displayName: 'LargeTitle' });
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`LargeTitle renders a default state 1`] = `
<div>
<span
class=""
>
Default LargeTitle
</span>
</div>
`;
1 change: 1 addition & 0 deletions packages/react-text/src/components/LargeTitle/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './LargeTitle';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as React from 'react';
import { render } from '@testing-library/react';
import { Subheadline } from './Subheadline';
import { isConformant } from '../../common/isConformant';

describe('Subheadline', () => {
isConformant({
Component: Subheadline,
displayName: 'Subheadline',
});

it('renders a default state', () => {
const result = render(<Subheadline>Default Subheadline</Subheadline>);
expect(result.container).toMatchSnapshot();
});
});
15 changes: 15 additions & 0 deletions packages/react-text/src/components/Subheadline/Subheadline.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { makeStyles } from '@fluentui/react-make-styles';
import { typographyStyles } from '../../index';
import { createWrapper } from '../wrapper';

/**
* Styles for the root slot
*/
const useStyles = makeStyles({
root: typographyStyles.subheadline,
});

/**
* Text wrapper component for the Subheadline typography variant
*/
export const Subheadline = createWrapper({ useStyles, displayName: 'Subheadline' });
Loading