From cd79fe1a7c1b3d6670024ae1f20d533d634fd77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Fern=C3=A1ndez?= Date: Wed, 10 Apr 2024 18:23:31 +0200 Subject: [PATCH] Grafana UI: `ThemeDemo` - Replace `HorizontalGroup` and `VerticalGroup` with `Stack` and `Box` (#85888) --- .betterer.results | 4 - .../src/components/ThemeDemos/ThemeDemo.tsx | 119 +++++++++--------- 2 files changed, 56 insertions(+), 67 deletions(-) diff --git a/.betterer.results b/.betterer.results index 041c00af5e6..866eb02a62b 100644 --- a/.betterer.results +++ b/.betterer.results @@ -991,10 +991,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/ThemeDemos/EmotionPerfTest.tsx:5381": [ [0, 0, 0, "\'VerticalGroup\' import from \'../Layout/Layout\' is restricted from being used by a pattern. Use Stack component instead.", "0"] ], - "packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx:5381": [ - [0, 0, 0, "\'HorizontalGroup\' import from \'../Layout/Layout\' is restricted from being used by a pattern. Use Stack component instead.", "0"], - [0, 0, 0, "\'VerticalGroup\' import from \'../Layout/Layout\' is restricted from being used by a pattern. Use Stack component instead.", "1"] - ], "packages/grafana-ui/src/components/ToolbarButton/ToolbarButton.story.tsx:5381": [ [0, 0, 0, "\'HorizontalGroup\' import from \'../Layout/Layout\' is restricted from being used by a pattern. Use Stack component instead.", "0"], [0, 0, 0, "\'VerticalGroup\' import from \'../Layout/Layout\' is restricted from being used by a pattern. Use Stack component instead.", "1"] diff --git a/packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx b/packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx index ccfea2e4dff..7ef26ad74ef 100644 --- a/packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx +++ b/packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.tsx @@ -13,47 +13,40 @@ import { InlineFieldRow } from '../Forms/InlineFieldRow'; import { RadioButtonGroup } from '../Forms/RadioButtonGroup/RadioButtonGroup'; import { Icon } from '../Icon/Icon'; import { Input } from '../Input/Input'; -import { HorizontalGroup, VerticalGroup } from '../Layout/Layout'; +import { BackgroundColor, BorderColor, Box } from '../Layout/Box/Box'; +import { Stack } from '../Layout/Stack/Stack'; import { Select } from '../Select/Select'; import { Switch } from '../Switch/Switch'; +import { Text, TextProps } from '../Text/Text'; interface DemoBoxProps { - bg?: string; - border?: string; - textColor?: string; + bg?: BackgroundColor; + border?: BorderColor; + textColor?: TextProps['color']; } const DemoBox = ({ bg, border, children }: React.PropsWithChildren) => { - const style = cx( - css({ - padding: '16px', - background: bg ?? 'inherit', - width: '100%', - }), - border - ? css({ - border: `1px solid ${border}`, - }) - : null + return ( + + {children} + ); - - return
{children}
; }; const DemoText = ({ color, bold, - size, children, -}: React.PropsWithChildren<{ color?: string; bold?: boolean; size?: number }>) => { - const style = css({ - padding: '4px', - color: color ?? 'inherit', - fontWeight: bold ? 500 : 400, - fontSize: `${size ?? 14}px`, - }); - - return
{children}
; +}: React.PropsWithChildren<{ color?: TextProps['color']; bold?: boolean; size?: number }>) => { + return ( + + {children && ( + + {children} + + )} + + ); }; export const ThemeDemo = () => { @@ -90,31 +83,31 @@ export const ThemeDemo = () => { color: t.colors.text.primary, })} > - + t.colors.background.canvas - + t.colors.background.primary is the main & preferred content - + t.colors.background.secondary and t.colors.border.layer1 - + - + - + - + - + @@ -134,7 +127,7 @@ export const ThemeDemo = () => { - + @@ -147,7 +140,7 @@ export const ThemeDemo = () => { - + setBoolValue(e.currentTarget.checked)} /> @@ -157,8 +150,8 @@ export const ThemeDemo = () => { - - + +
Inline forms
@@ -168,22 +161,22 @@ export const ThemeDemo = () => { -
+
- - + + {Object.entries(t.shadows).map(([key, value]) => ( ))} - + - - - + + + {allButtonVariants.map((variant) => ( - + Button inside card @@ -206,7 +199,7 @@ export const ThemeDemo = () => { - + @@ -290,16 +283,16 @@ const colorsTableStyle = css({ export function TextColors({ t }: { t: GrafanaTheme2 }) { return ( <> - + text.primary - + text.secondary - + text.disabled - + primary.text @@ -334,34 +327,34 @@ export function ActionsDemo() { }); return ( - - - + + +
item
item
item hover
item selected
item focused
-
+
- - + +
item
item
item hover
item selected
item focused
-
+
- - + +
item
item
item hover
item selected
item focused
-
+
-
+ ); }