Skip to content

Commit

Permalink
Fix scroll documentation usages + simplify snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Aug 17, 2022
1 parent 72eb74f commit a0b5625
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 46 deletions.
17 changes: 12 additions & 5 deletions src-docs/src/views/scroll/scroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import React, { useContext } from 'react';

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

import { EuiCode, useEuiScrollBar, useEuiTheme } from '../../../../src';
import {
EuiCode,
useEuiScrollBar,
useEuiTheme,
logicalCSS,
logicalCSSWithFallback,
} from '../../../../src';
import { ThemeExample } from '../theme/_components/_theme_example';
import { ScrollContent } from './_scroll_content';

Expand Down Expand Up @@ -40,7 +46,8 @@ export default () => {
className="eui-scrollBar"
style={{
overflowY: 'auto',
height: euiTheme.base * 10,
overflowBlock: 'auto',
blockSize: euiTheme.base * 10,
}}
>
<ScrollContent />
Expand All @@ -51,7 +58,7 @@ export default () => {
role="region"
aria-label=""
className="eui-scrollBar"
style={{ overflowY: 'auto', euiTheme.base * 10 }}>
>
<EuiPanel />
<EuiPanel />
<EuiPanel />
Expand Down Expand Up @@ -85,8 +92,8 @@ export default () => {
aria-label="Example of useEuiScrollBar region"
css={css`
${useEuiScrollBar()}
overflow-y: auto;
height: ${euiTheme.base * 10}px;
${logicalCSSWithFallback('overflow-y', 'auto')}
${logicalCSS('height', `${euiTheme.base * 10}px`)}
`}
>
<ScrollContent />
Expand Down
31 changes: 8 additions & 23 deletions src-docs/src/views/scroll/scroll_x.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
useEuiTheme,
EuiLink,
useEuiOverflowScroll,
logicalCSS,
} from '../../../../src';
import { ThemeExample } from '../theme/_components/_theme_example';
import { ScrollContent } from './_scroll_content';
Expand All @@ -23,7 +24,7 @@ export default () => {
const scrollingContent = (
<EuiFlexGroup
css={css`
width: 150%;
${logicalCSS('width', '150%')}
`}
responsive={false}
>
Expand Down Expand Up @@ -53,25 +54,21 @@ export default () => {
role="region"
aria-label="Example of eui-xScroll region"
className="eui-xScrollWithShadows"
style={{ padding: `${euiTheme.size.base}` }}
style={{ padding: euiTheme.size.base }}
>
{scrollingContent}
</div>
}
snippet={
`<div
snippet={`<div
tabIndex={0}
role="region"
aria-label=""
className="eui-xScrollWithShadows"
style={{ padding: ` +
'`${euiTheme.size.base}`' +
` }}>
>
<EuiPanel />
<EuiPanel />
<EuiPanel />
</div>`
}
</div>`}
/>

{!showSass && (
Expand Down Expand Up @@ -107,20 +104,8 @@ export default () => {
{scrollingContent}
</div>
}
snippet={
`<div
tabIndex={0}
role="region"
aria-label=""
css={css` +
"`${useEuiOverflowScroll('x', true)}; " +
'padding: ${euiTheme.size.base};`' +
` }}>
<EuiPanel />
<EuiPanel />
<EuiPanel />
</div>`
}
snippet="${useEuiOverflowScroll('x', true)}"
snippetLanguage="emotion"
/>
)}

Expand Down
29 changes: 11 additions & 18 deletions src-docs/src/views/scroll/scroll_y.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { css } from '@emotion/react';

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

import { EuiCode, EuiLink, useEuiOverflowScroll } from '../../../../src';
import {
EuiCode,
EuiLink,
useEuiOverflowScroll,
logicalCSS,
} from '../../../../src';
import { ThemeExample } from '../theme/_components/_theme_example';
import { ScrollContent } from './_scroll_content';

Expand Down Expand Up @@ -43,7 +48,7 @@ export default () => {
role="region"
aria-label=""
className="eui-yScrollWithShadows"
style={{ height: 180 }}>
>
<EuiPanel />
<EuiPanel />
<EuiPanel />
Expand Down Expand Up @@ -76,27 +81,15 @@ export default () => {
role="region"
aria-label="Example of useEuiOverflowScroll(y) region"
css={css`
${useEuiOverflowScroll('y', true)};
height: 180px;
${useEuiOverflowScroll('y', true)}
${logicalCSS('height', '180px')}
`}
>
<ScrollContent />
</div>
}
snippet={
`<div
tabIndex={0}
role="region"
aria-label=""
css={css` +
"`${useEuiOverflowScroll('y', true)}; " +
'height: 180px;' +
` }}>
<EuiPanel />
<EuiPanel />
<EuiPanel />
</div>`
}
snippet="${useEuiOverflowScroll('y', true)}"
snippetLanguage="emotion"
/>
)}

Expand Down

0 comments on commit a0b5625

Please sign in to comment.