Skip to content

Commit

Permalink
Optimise use of flex-grow/margin auto spacing
Browse files Browse the repository at this point in the history
Using new Box component where appropriate
  • Loading branch information
felixhabib committed Jun 5, 2024
1 parent b3a29c6 commit 69643c0
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 55 deletions.
39 changes: 13 additions & 26 deletions src/Playroom/Frames/Frames.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,20 @@ export const root = style([
}),
]);

export const framesContainer = style([
sprinkles({
display: 'flex',
gap: 'gutter',
}),
{
marginInline: 'auto',
},
]);
export const frameContainer = sprinkles({
position: 'relative',
height: 'full',
textAlign: 'left',
display: 'flex',
flexDirection: 'column',
});

export const frameContainer = style([
sprinkles({
position: 'relative',
height: 'full',
textAlign: 'left',
display: 'flex',
flexDirection: 'column',
}),
{},
]);

export const frame = style([
sprinkles({ position: 'relative', height: 'full', border: 0 }),
{
flexGrow: 1,
},
]);
export const frame = sprinkles({
position: 'relative',
height: 'full',
border: 0,
flexGrow: 1,
});

export const frameBorder = style([
sprinkles({
Expand Down
5 changes: 3 additions & 2 deletions src/Playroom/Frames/Frames.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import playroomConfig from '../../config';
import frameSrc from './frameSrc';

import * as styles from './Frames.css';
import { Box } from '../Box/Box';

interface FramesProps {
code: string;
Expand All @@ -34,7 +35,7 @@ export default function Frames({ code, themes, widths }: FramesProps) {

return (
<div ref={scrollingPanelRef} className={styles.root}>
<div className={styles.framesContainer}>
<Box display="flex" gap="gutter" marginX="auto">
{frames.map((frame) => (
<div
key={`${frame.theme}_${frame.width}`}
Expand Down Expand Up @@ -65,7 +66,7 @@ export default function Frames({ code, themes, widths }: FramesProps) {
</div>
</div>
))}
</div>
</Box>
</div>
);
}
4 changes: 0 additions & 4 deletions src/Playroom/FramesPanel/FramesPanel.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { globalStyle, style } from '@vanilla-extract/css';
import { colorPaletteVars, sprinkles } from '../sprinkles.css';
import { vars } from '../vars.css';

export const title = style({
marginRight: 'auto',
});

export const reset = style([
sprinkles({
position: 'relative',
Expand Down
9 changes: 5 additions & 4 deletions src/Playroom/FramesPanel/FramesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { ToolbarPanel } from '../ToolbarPanel/ToolbarPanel';
import { StoreContext } from '../../StoreContext/StoreContext';
import { Stack } from '../Stack/Stack';
import { Text } from '../Text/Text';

import * as styles from './FramesPanel.css';
import { Helmet } from 'react-helmet';
import { Inline } from '../Inline/Inline';
import { Box } from '../Box/Box';

import * as styles from './FramesPanel.css';

const getTitle = (title: string | undefined) => {
if (title) {
Expand Down Expand Up @@ -47,9 +48,9 @@ interface FrameHeadingProps {
}
const FrameHeading = ({ showReset, onReset, children }: FrameHeadingProps) => (
<Inline space="none" alignY="center">
<div className={styles.title}>
<Box flexGrow={1}>
<Heading level="3">{children}</Heading>
</div>
</Box>
{showReset && <ResetButton onClick={onReset}>Clear</ResetButton>}
</Inline>
);
Expand Down
8 changes: 0 additions & 8 deletions src/Playroom/SettingsPanel/SettingsPanel.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ export const fieldset = sprinkles({
padding: 'none',
});

export const keyboardShortcutsRow = sprinkles({
alignItems: 'center',
});

export const keyboardShortcutTitle = style({
marginRight: 'auto',
});

export const keyboardShortcutKeys = style([
{
display: 'grid',
Expand Down
5 changes: 3 additions & 2 deletions src/Playroom/SettingsPanel/SettingsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ColorModeDarkIcon from '../icons/ColorModeDarkIcon';
import { Text } from '../Text/Text';
import { Inline } from '../Inline/Inline';
import { isMac } from '../../utils/formatting';
import { Box } from '../Box/Box';

const getKeyBindings = () => {
const metaKeySymbol = isMac() ? '⌘' : 'Ctrl';
Expand Down Expand Up @@ -72,9 +73,9 @@ const KeyboardShortcut = ({

return (
<Inline space="small" alignY="center">
<div className={styles.keyboardShortcutTitle}>
<Box flexGrow={1}>
<Text>{description}</Text>
</div>
</Box>
<Text size={isMac() ? 'large' : 'standard'}>
<div className={styles.keyboardShortcutKeys}>{shortcutSegments}</div>
</Text>
Expand Down
4 changes: 0 additions & 4 deletions src/Playroom/Toolbar/Toolbar.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ export const sidebar = sprinkles({
overflow: 'hidden',
});

export const topButtons = sprinkles({
transition: 'medium',
});

export const positions_isOpen = style({});
export const positionContainer = style([
sprinkles({
Expand Down
2 changes: 1 addition & 1 deletion src/Playroom/Toolbar/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default ({ themes: allThemes, widths: allWidths, snippets }: Props) => {
)}
<div className={styles.sidebar}>
<div className={styles.buttons}>
<div className={styles.topButtons}>
<div>
{hasSnippets && (
<ToolbarItem
active={isSnippetsOpen}
Expand Down
9 changes: 5 additions & 4 deletions src/Playroom/sprinkles.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const responsiveProperties = defineProperties({
display: ['none', 'flex', 'block', 'inline'],
flexDirection: ['row', 'column', 'row-reverse'],
flexWrap: ['wrap'],
flexGrow: [0, 1],
justifyContent: [
'stretch',
'flex-start',
Expand All @@ -69,10 +70,10 @@ const responsiveProperties = defineProperties({
paddingBottom: vars.space,
paddingLeft: vars.space,
paddingRight: vars.space,
marginTop: vars.space,
marginBottom: vars.space,
marginLeft: vars.space,
marginRight: vars.space,
marginTop: { ...vars.space, auto: 'auto' },
marginBottom: { ...vars.space, auto: 'auto' },
marginLeft: { ...vars.space, auto: 'auto' },
marginRight: { ...vars.space, auto: 'auto' },
overflow: ['hidden', 'auto'],
boxShadow: colorPaletteVars.shadows,
borderRadius: vars.radii,
Expand Down

0 comments on commit 69643c0

Please sign in to comment.