-
Phoomparin Mano authored
* support test utilities in sdk import * add relative unit default chart font size in embedding defaults * make font size follow sdk root * feat(sdk): add font size settings to axis ticks * feat(sdk): add font size settings to series labels * re-add hasTimelineEvents from merge commits * apply default font size at the theme level * add table header cell font size * calculate cell font size based on 12.5px * rename theme.chart to theme.cartesian * refactor visualization theme * refactor default viz theme * remove chart style config * add goal line * pass font size to chart measurements * use px as reference unit * support row chart viz * add missing echarts font size * add table cell font sizes * use css variables for funnel color * fix theme type in smart scalar story * add bar chart to storybook for visual test * add line chart to storybook for visual test * add loki reference images * add loki reference images for row chart * add loki shared reference images to stories filter * update loki reference image * synchronize base font size * add theme provider to funnel test setup * add missing default visualization theme * add unit test for get size in px * update loki reference image * fix static viz build error
Phoomparin Mano authored* support test utilities in sdk import * add relative unit default chart font size in embedding defaults * make font size follow sdk root * feat(sdk): add font size settings to axis ticks * feat(sdk): add font size settings to series labels * re-add hasTimelineEvents from merge commits * apply default font size at the theme level * add table header cell font size * calculate cell font size based on 12.5px * rename theme.chart to theme.cartesian * refactor visualization theme * refactor default viz theme * remove chart style config * add goal line * pass font size to chart measurements * use px as reference unit * support row chart viz * add missing echarts font size * add table cell font sizes * use css variables for funnel color * fix theme type in smart scalar story * add bar chart to storybook for visual test * add line chart to storybook for visual test * add loki reference images * add loki reference images for row chart * add loki shared reference images to stories filter * update loki reference image * synchronize base font size * add theme provider to funnel test setup * add missing default visualization theme * add unit test for get size in px * update loki reference image * fix static viz build error
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
SdkContentWrapper.tsx 2.78 KiB
import { css } from "@emotion/react";
import styled from "@emotion/styled";
import type { HTMLAttributes } from "react";
import { getRootStyle } from "metabase/css/core/base.styled";
import { defaultFontFiles } from "metabase/css/core/fonts.styled";
import { alpha, lighten } from "metabase/lib/colors";
import { useSelector } from "metabase/lib/redux";
import { aceEditorStyles } from "metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.styled";
import { getFontFiles } from "metabase/styled-components/selectors";
import { saveDomImageStyles } from "metabase/visualizations/lib/save-chart-image";
import type { FontFile } from "metabase-types/api";
interface SdkContentWrapperProps {
baseUrl?: string;
}
export function SdkContentWrapper({
baseUrl,
...divProps
}: SdkContentWrapperProps & HTMLAttributes<HTMLDivElement>) {
const fontFiles = useSelector(getFontFiles);
return (
<SdkContentWrapperInner
baseUrl={baseUrl}
fontFiles={fontFiles}
{...divProps}
/>
);
}
const SdkContentWrapperInner = styled.div<
SdkContentWrapperProps & {
fontFiles: FontFile[] | null;
}
>`
--mb-default-font-family: "${({ theme }) => theme.fontFamily}";
--mb-color-bg-light: ${({ theme }) => theme.fn.themeColor("bg-light")};
--mb-color-bg-dark: ${({ theme }) => theme.fn.themeColor("bg-dark")};
--mb-color-brand: ${({ theme }) => theme.fn.themeColor("brand")};
--mb-color-brand-lighter: ${({ theme }) =>
lighten(theme.fn.themeColor("brand"), 0.598)};
--mb-color-brand-alpha-04: ${({ theme }) =>
alpha(theme.fn.themeColor("brand"), 0.04)};
--mb-color-brand-alpha-88: ${({ theme }) =>
alpha(theme.fn.themeColor("brand"), 0.88)};
--mb-color-focus: ${({ theme }) => theme.fn.themeColor("focus")};
--mb-color-bg-white: ${({ theme }) => theme.fn.themeColor("bg-white")};
--mb-color-bg-black: ${({ theme }) => theme.fn.themeColor("bg-black")};
--mb-color-shadow: ${({ theme }) => theme.fn.themeColor("shadow")};
--mb-color-border: ${({ theme }) => theme.fn.themeColor("border")};
--mb-color-text-dark: ${({ theme }) => theme.fn.themeColor("text-dark")};
--mb-color-text-medium: ${({ theme }) => theme.fn.themeColor("text-medium")};
--mb-color-text-light: ${({ theme }) => theme.fn.themeColor("text-light")};
font-size: ${({ theme }) => theme.other.fontSize};
${aceEditorStyles}
${saveDomImageStyles}
${({ theme }) => getRootStyle(theme)}
${({ baseUrl }) => defaultFontFiles({ baseUrl })}
${({ fontFiles }) =>
fontFiles?.map(
file => css`
@font-face {
font-family: "Custom";
src: url(${encodeURI(file.src)}) format("${file.fontFormat}");
font-weight: ${file.fontWeight};
font-style: normal;
font-display: swap;
}
`,
)}
:where(svg) {
display: inline;
}
`;