Skip to content

Commit

Permalink
Fix various flyout width issues
Browse files Browse the repository at this point in the history
- fix responsive flyout behavior by removing `max-width: none` from inline styles (was overriding max-width 90vw CSS media query)
- add noMaxWidth Emotion class instead, which can be overridden by said media query

- revert m sized flyouts to `424px` wide min widths
- fix max-width for m sized flyouts missing a `px` unit
- remove unnecessary `Math.round` from l.max

- update inline custom max-width/width styles to use logical properties
  • Loading branch information
cee-chen committed Sep 14, 2022
1 parent 5dbe365 commit 937695a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/components/flyout/flyout.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { UseEuiTheme } from '../../services';
import { euiShadowXLarge } from '../../themes/amsterdam/global_styling/mixins';
import { transparentize } from '../../services/color';
import { euiFormMaxWidth } from '../form/form.styles';

const euiFlyoutSlideInRight = keyframes`
0% {
Expand Down Expand Up @@ -117,6 +118,9 @@ export const euiFlyoutStyles = (euiThemeContext: UseEuiTheme) => {
l: css`
${composeFlyoutSizing(euiThemeContext, 'l')}
`,
noMaxWidth: css`
${logicalCSS('max-width', 'none')}
`,

// Side
right: css`
Expand Down Expand Up @@ -185,15 +189,16 @@ const composeFlyoutSizing = (
},

m: {
min: `${euiTheme.breakpoint.m * 0.8}px`,
// Calculated for forms plus padding
min: `${mathWithUnits(euiFormMaxWidth(euiThemeContext), (x) => x + 24)}`,
width: '50vw',
max: euiTheme.breakpoint.m,
max: `${euiTheme.breakpoint.m}px`,
},

l: {
min: `${Math.round(euiTheme.breakpoint.m * 0.9)}px`,
width: '75vw',
max: `${Math.round(euiTheme.breakpoint.l)}px`,
max: `${euiTheme.breakpoint.l}px`,
},
};

Expand Down
8 changes: 5 additions & 3 deletions src/components/flyout/flyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
useIsWithinMinBreakpoint,
useEuiTheme,
} from '../../services';
import { logicalStyle } from '../../global_styling';

import { CommonProps, PropsOfElement } from '../common';
import { EuiFocusTrap, EuiFocusTrapProps } from '../focus_trap';
Expand Down Expand Up @@ -244,13 +245,13 @@ export const EuiFlyout = forwardRef(

let newStyle;

if (maxWidth !== true) {
newStyle = { ...style, maxWidth: maxWidth === false ? 'none' : maxWidth };
if (typeof maxWidth !== 'boolean') {
newStyle = { ...style, ...logicalStyle('max-width', maxWidth) };
}

// Setting size
if (!isEuiFlyoutSizeNamed(size)) {
newStyle = { ...(newStyle || style), width: size };
newStyle = { ...(newStyle || style), ...logicalStyle('width', size) };
}

const euiTheme = useEuiTheme();
Expand All @@ -260,6 +261,7 @@ export const EuiFlyout = forwardRef(
styles.euiFlyout,
styles.paddingSizes[paddingSize],
isEuiFlyoutSizeNamed(size) && styles[size],
maxWidth === false && styles.noMaxWidth,
styles[type],
type === 'push' && styles.pushSide[side],
styles[side],
Expand Down

0 comments on commit 937695a

Please sign in to comment.