From 39a18ca6ba8d46c5e10572d8ab44affb0785f516 Mon Sep 17 00:00:00 2001 From: Sven Grossmann Date: Tue, 20 Jun 2023 12:31:38 +0200 Subject: [PATCH] Frontend: Fix frontend styleguide emotion example (#70371) fix wrong example --- contribute/style-guides/styling.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contribute/style-guides/styling.md b/contribute/style-guides/styling.md index 6dd61117c15..73790ce463b 100644 --- a/contribute/style-guides/styling.md +++ b/contribute/style-guides/styling.md @@ -39,8 +39,9 @@ can have your getStyles function return an object with many class names and use Let's say you need to style a component that has a different background depending on the `isActive` property : ```tsx -import React from 'react'; import { css, cx } from '@emotion/css'; +import React from 'react'; + import { GrafanaTheme2 } from '@grafana/data'; import { useStyles2 } from '@grafana/ui'; @@ -49,8 +50,7 @@ interface ComponentAProps { } const ComponentA = ({ isActive }: ComponentAProps) => { - const theme = useTheme(); - const styles = useStyles2(theme); + const styles = useStyles2(getStyles); return (
@@ -64,15 +64,15 @@ const ComponentA = ({ isActive }: ComponentAProps) => { const getStyles = (theme: GrafanaTheme2) => { return { wrapper: css({ - background: theme.colors.background.secondary; + background: theme.colors.background.secondary, }), active: css({ background: theme.colors.primary.main, text: theme.colors.primary.contrastText, - }, + }), icon: css({ - fontSize: theme.typography.bodySmall.fontSize; - }) + fontSize: theme.typography.bodySmall.fontSize, + }), }; }; ```