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

[Docs] Fixing the logic for shadow and border combinations of EuiPanel #5623

Merged
merged 1 commit into from
Feb 11, 2022
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
13 changes: 6 additions & 7 deletions src-docs/src/views/panel/panel_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,19 @@ export const PanelExample = {
<p>
<strong>EuiPanel</strong> can give depth to your container with{' '}
<EuiCode>hasShadow</EuiCode> while <EuiCode>hasBorder</EuiCode> can
add containment. Just be sure not to include too many nested panels
with these settings.
add containment. Just be sure not to include too many{' '}
<Link to="/layout/panel/guidelines">nested panels</Link> with these
settings.
</p>
<EuiCallOut
color="warning"
title="Certain allowed combinations of shadow, border, and color depend on the current theme."
>
<p>
For instance, only plain or transparent panels can have a border
and/or shadow. The Amsterdam theme doesn&apos;t allow combining
the <EuiCode>hasBorder</EuiCode> option with{' '}
<EuiCode>hasShadow</EuiCode>. The default theme only allows
removing the border if both <EuiCode>hasShadow</EuiCode> and{' '}
<EuiCode>hasBorder</EuiCode> are set to <EuiCode>false</EuiCode>.
and/or shadow. The default theme doesn&apos;t allow combining the{' '}
<EuiCode>hasBorder</EuiCode> option with{' '}
<EuiCode>hasShadow</EuiCode>.
</p>
</EuiCallOut>
</>
Expand Down
38 changes: 21 additions & 17 deletions src-docs/src/views/panel/panel_shadow.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React, { useContext } from 'react';

import { EuiPanel, EuiCode, EuiSpacer } from '../../../../src/components';
import { ThemeContext } from '../../components';
import React from 'react';
import {
EuiPanel,
EuiCode,
EuiSpacer,
LEGACY_NAME_KEY,
useEuiTheme,
} from '../../../../src';

export default () => {
const themeContext = useContext(ThemeContext);
const isAmsterdamTheme = !themeContext.theme.includes('legacy');
const { euiTheme } = useEuiTheme();
const isLegacyTheme = euiTheme.themeName.includes(LEGACY_NAME_KEY);

return (
<div>
Expand All @@ -15,19 +19,19 @@ export default () => {

<EuiSpacer />

{/* This example only works for the Amsterdam theme. The default theme has `hasBorder={true}` by default. */}
{isAmsterdamTheme && (
<>
<EuiPanel hasBorder={true}>
<EuiCode>{'hasBorder={true}'}</EuiCode>
</EuiPanel>
<EuiSpacer />
</>
{/* This example only works for the default theme. The legacy theme has `hasBorder={true}` by default. */}
{!isLegacyTheme && (
<EuiPanel hasBorder={true}>
<EuiCode>{'hasBorder={true}'}</EuiCode>
</EuiPanel>
)}

<EuiPanel hasShadow={false} hasBorder={false}>
<EuiCode>{'hasShadow={false} hasBorder={false}'}</EuiCode>
</EuiPanel>
{/* This example only matters for the legacy theme. The default theme has `hasBorder={false}` by default. */}
{isLegacyTheme && (
<EuiPanel hasShadow={false} hasBorder={false}>
<EuiCode>{'hasShadow={false} hasBorder={false}'}</EuiCode>
</EuiPanel>
)}
</div>
);
};