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

Swap usages of code for code block and fix overflow #6

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
5 changes: 3 additions & 2 deletions src-docs/src/components/guide_section/_guide_section.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
height: $euiSizeL;
}

.guideSection__table-row {
overflow: auto;
.guideSection__tableCodeBlock {
padding-left: $euiSizeXS;
padding-right: $euiSizeXS;
}
44 changes: 24 additions & 20 deletions src-docs/src/components/guide_section/guide_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ export class GuideSection extends Component {
type,
} = props[propName];

const codeBlockProps = {
className: 'guideSection__tableCodeBlock',
paddingSize: 'none',
language: 'ts',
};

let humanizedName = (
<strong className="eui-textBreakNormal">{propName}</strong>
);
Expand Down Expand Up @@ -332,21 +338,18 @@ export class GuideSection extends Component {
let defaultValueMarkup = '';
if (defaultValue) {
defaultValueMarkup = [
<EuiCode key={`defaultValue-${propName}`}>
<span className="eui-textBreakNormal">{defaultValue.value}</span>
</EuiCode>,
<EuiCodeBlock {...codeBlockProps} key={`defaultValue-${propName}`}>
{defaultValue.value}
</EuiCodeBlock>,
];
if (defaultValue.comment) {
defaultValueMarkup.push(`(${defaultValue.comment})`);
}
}

let defaultTypeCell = (
<EuiTableRowCell
className="guideSection__table-row"
key="type"
header="Type">
<EuiCode>{typeMarkup}</EuiCode>
<EuiTableRowCell key="type" header="Type" textOnly={false}>
<EuiCodeBlock {...codeBlockProps}>{typeMarkup}</EuiCodeBlock>
</EuiTableRowCell>
);
if (functionMatches.length > 0) {
Expand All @@ -355,28 +358,29 @@ export class GuideSection extends Component {
for (let i = 0; i < types.length; i++) {
if (functionMatches[j]) {
elements.push(
<EuiCode>
<span className="eui-textBreakNormal">{types[i]}</span>
</EuiCode>
<Fragment>
{types[i]} <br />
</Fragment>
);
elements.push(
<EuiCode language="ts">{functionMatches[j][0]}</EuiCode>
<Fragment>
{functionMatches[j][0]} <br />
</Fragment>
);
j++;
} else {
elements.push(
<EuiCode>
<span className="eui-textBreakNormal">{types[i]}</span>
</EuiCode>
<Fragment>
{types[i]} <br />
</Fragment>
);
}
}
defaultTypeCell = (
<EuiTableRowCell
className="guideSection__table-row"
key="type"
header="Type">
{elements}
<EuiTableRowCell key="type" header="Type" textOnly={false}>
<EuiCodeBlock whiteSpace="pre" {...codeBlockProps}>
{elements}
</EuiCodeBlock>
</EuiTableRowCell>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/code/_code_block.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.euiCodeBlock {
max-width: 100%;
display: block;
position: relative;
background: $euiCodeBlockBackgroundColor;
Expand Down