Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Emotion] Convert Sass typography mixins to JS #5854

Merged
merged 18 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c966bca
Add unit tests for euiFontSize mixin
cee-chen Apr 27, 2022
16c7195
Convert euiTextBreakWord to function + add unit test
cee-chen Apr 27, 2022
db454d8
[misc] fix downstream mounted snapshot by changing to render
cee-chen Apr 27, 2022
90fc6de
Convert euiTextTruncate mixin from Sass to CSS-in-JS
cee-chen Apr 27, 2022
c1a3273
Convert euiNumberFormat mixin from Sass to CSS-in-JS
cee-chen Apr 27, 2022
545eba1
Convert euiTextShift from Sass to CSS-in-JS + move to `functions` rat…
cee-chen Apr 28, 2022
27ac2f3
[Docs] Move text utilities to their own page
cee-chen Apr 28, 2022
c4f1e5e
[Docs] Split text utilities into sections + add mixin snippets
cee-chen Apr 28, 2022
9fe7b65
[Docs] Add prop to ThemeExample that allows stacking/removing margin-…
cee-chen Apr 28, 2022
14c4604
[PR feedback] Remove margin-bottom/stacking behavior - Caroline will …
cee-chen Apr 29, 2022
ab3f6b1
[PR feedback] Documentation copy + example fixes
cee-chen May 2, 2022
e257273
[PR feedback] Comment copy, remove IE workaround
cee-chen May 2, 2022
a3cff1f
[PR feedback] DRY out unit measurement tests
cee-chen May 2, 2022
65517bf
[PR feedback] Fix euiNumberFormat to use `euiTheme.font.featureSettings`
cee-chen May 2, 2022
ec27f55
[PR feedback] Add callouts to CSS utilities docs page
cee-chen May 2, 2022
b4d2c2d
[PR feedback] Tweak text align documentation
cee-chen May 2, 2022
b0467f8
[PR feedback] Document euiTextTruncate parameters in title
constancecchen May 2, 2022
e38cd3a
Add changelog entry
cee-chen May 2, 2022
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
3 changes: 3 additions & 0 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ import { TextDiffExample } from './views/text_diff/text_diff_example';

import { TextExample } from './views/text/text_example';

import { TextUtilitiesExample } from './views/text_utilities/text_utilities_example';

import { TimelineExample } from './views/timeline/timeline_example';

import { TitleExample } from './views/title/title_example';
Expand Down Expand Up @@ -598,6 +600,7 @@ const navigation = [
ResponsiveExample,
ScrollExample,
TextDiffExample,
TextUtilitiesExample,
WindowEventExample,
].map((example) => createExample(example)),
},
Expand Down
62 changes: 62 additions & 0 deletions src-docs/src/views/text_utilities/align.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react';

import { EuiCode, EuiMark } from '../../../../src';
import { ThemeExample } from '../theme/_components/_theme_example';

export default () => (
<>
<ThemeExample
title={<code>.eui-textLeft</code>}
description={
<p>
Changes the element’s text alignment property to{' '}
<EuiCode language="sass">text-align: left;</EuiCode>
Copy link
Contributor

Choose a reason for hiding this comment

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

I just realized we need to be changing these all to logical properties. 😬

Copy link
Contributor

Choose a reason for hiding this comment

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

I would still keep the name of the thing as left and right, but the output should be logical.

Copy link
Member Author

Choose a reason for hiding this comment

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

As in I should be changing this in Sass itself? Could we maybe wait until we convert our Sass-only text utils to CSS-in-JS globals before doing this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry no, I didn't realize this PR didn't contain the JS version of the Sass utility. When we do convert the pure utility, we need to make sure output uses the logical properties. Then in this description, instead of explicitly saying what the output style is, we'd just say something like:

Suggested change
<EuiCode language="sass">text-align: left;</EuiCode>
be aligned to the left (starting) side of its container.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh gotcha! Makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

I made that documentation tweak while here since I figured it was easy enough - LMK if you'd rather revert/wait until we tackle Sass/Emotion globals b4d2c2d

</p>
}
example={
<div className="eui-textLeft">
<EuiMark>Left align text</EuiMark>
</div>
}
snippet={`<div className="eui-textLeft">
/* Your content */
</div>`}
/>

<ThemeExample
title={<code>.eui-textCenter</code>}
description={
<p>
Changes the element’s text alignment property to{' '}
<EuiCode language="sass">text-align: center;</EuiCode>
</p>
}
example={
<div className="eui-textCenter">
<EuiMark>Center align text</EuiMark>
</div>
}
snippet={`<div className="eui-textCenter">
/* Your content */
</div>`}
/>

<ThemeExample
title={<code>.eui-textRight</code>}
description={
<p>
Changes the element’s text alignment property to{' '}
<EuiCode language="sass">text-align: right;</EuiCode>
</p>
}
example={
<div className="eui-textRight">
<EuiMark>Right align text</EuiMark>
</div>
}
snippet={`<div className="eui-textRight">
/* Your content */
</div>`}
/>
</>
);
32 changes: 32 additions & 0 deletions src-docs/src/views/text_utilities/color.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { Link } from 'react-router-dom';

import { EuiCode, EuiTextColor } from '../../../../src';
import { ThemeExample } from '../theme/_components/_theme_example';

export default () => (
<ThemeExample
title={<code>.eui-textInheritColor</code>}
description={
<>
<p>Forces the component to inherit its text color from its parent.</p>
<p>
For changing the color of your text to on of the named colors,{' '}
<Link to="/display/text#coloring-text">
use <strong>EuiText</strong> or <strong>EuiTextColor</strong>
</Link>
.
</p>
</>
}
example={
<EuiTextColor color="danger">
<EuiCode className="eui-textInheritColor">I am code</EuiCode> that
matches the EuiTextColor
</EuiTextColor>
}
snippet={`<EuiTextColor color="danger">
<EuiCode className="eui-textInheritColor">I am danger code</EuiCode>
</EuiTextColor>`}
/>
);
90 changes: 90 additions & 0 deletions src-docs/src/views/text_utilities/numbers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import React, { useContext } from 'react';

import { ThemeContext } from '../../components/with_theme';

import {
EuiCode,
EuiTextAlign,
EuiFlexGrid,
EuiFlexItem,
} from '../../../../src';
import { ThemeExample } from '../theme/_components/_theme_example';

export default () => {
const themeContext = useContext(ThemeContext);
const currentLanguage = themeContext.themeLanguage;
const showSass = currentLanguage.includes('sass');

return (
<>
<ThemeExample
title={<code>.eui-textNumber</code>}
description={
<p>
Applies{' '}
<EuiCode language="sass">
{'font-feature-settings: "tnum";'}
</EuiCode>{' '}
so that numbers align more properly in a column, especially when
right aligned.
</p>
}
example={
<EuiTextAlign textAlign="right">
<EuiFlexGrid columns={2}>
<EuiFlexItem>
<p>
<strong>Without class</strong>
<br />
11317.11
<br />
0040.900
</p>
</EuiFlexItem>
<EuiFlexItem>
<p className="eui-textNumber">
<strong>With class</strong>
<br />
11317.11
<br />
0040.900
</p>
</EuiFlexItem>
</EuiFlexGrid>
</EuiTextAlign>
}
snippet={`<div className="eui-textNumber">
/* Your number content */
</div>`}
hasSpacing={false}
/>
{/* Mixin */}
{!showSass ? (
<ThemeExample
title={<code>euiNumberFormat()</code>}
description={
<p>
Use this style function to apply{' '}
<EuiCode>.eui-textNumber</EuiCode> within your CSS-in-JS styling.
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
No parameters are taken for this utility.
</p>
}
snippet={'${euiNumberFormat()}'}
snippetLanguage="emotion"
/>
) : (
<ThemeExample
title={<code>Mixin</code>}
description={
<p>
Use this Sass mixin to apply <EuiCode>.eui-textNumber</EuiCode>{' '}
within your classes. No parameters are taken for this utility.
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
</p>
}
snippet={'@include euiNumberFormat;'}
snippetLanguage="scss"
/>
)}
</>
);
};
45 changes: 45 additions & 0 deletions src-docs/src/views/text_utilities/text_utilities_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';

import { EuiText } from '../../../../src/components';

import TextAlignUtilities from './align';
import TextWrappingUtilities from './wrapping';
import TextNumberUtilities from './numbers';
import TextColorUtilities from './color';

export const TextUtilitiesExample = {
title: 'Text',
showThemeLanguageToggle: true,
intro: (
<EuiText>
<p>
These text utilities are available primarily as CSS classes to aid in
quickly tweaking your text. Some utilities are additionally available as
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
either CSS-in-JS or Sass mixins to optionally compose within your own
custom styles.
</p>
</EuiText>
),
sections: [
{
title: 'Alignment',
wrapText: false,
text: <TextAlignUtilities />,
},
{
title: 'Wrapping',
wrapText: false,
text: <TextWrappingUtilities />,
},
{
title: 'Numbers',
wrapText: false,
text: <TextNumberUtilities />,
},
{
title: 'Color',
wrapText: false,
text: <TextColorUtilities />,
},
],
};
Loading