Skip to content

Commit f84e2eb

Browse files
committed
Introduced Typography component
1 parent b0ee3e8 commit f84e2eb

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

dashi/src/lib/components/Component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Box, type BoxProps } from "./Box";
55
import { Checkbox, type CheckboxProps } from "./Checkbox";
66
import { Dropdown, type DropdownProps } from "./Dropdown";
77
import { Plot, type PlotProps } from "./Plot";
8+
import { Typography, type TypographyProps } from "@/lib/components/Typography";
89

910
export interface ComponentProps extends ComponentState {
1011
onChange: ComponentChangeHandler;
@@ -27,5 +28,7 @@ export function Component({ type, ...props }: ComponentProps) {
2728
return <Box {...(props as BoxProps)} />;
2829
} else if (type === "Checkbox") {
2930
return <Checkbox {...(props as CheckboxProps)} />;
31+
} else if (type === "Typography") {
32+
return <Typography {...(props as TypographyProps)} />;
3033
}
3134
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import MuiTypography from "@mui/material/Typography";
2+
3+
import type { TypographyState } from "@/lib/types/state/component";
4+
5+
export interface TypographyProps extends Omit<TypographyState, "type"> {}
6+
7+
export function Typography({ id, style, text }: TypographyProps) {
8+
return (
9+
<MuiTypography id={id} style={style}>
10+
{text}
11+
</MuiTypography>
12+
);
13+
}

dashi/src/lib/types/state/component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { type CSSProperties } from "react";
22
import type { VisualizationSpec } from "react-vega";
33

4-
export type ComponentType = "Button" | "Checkbox" | "Dropdown" | "Plot" | "Box";
4+
export type ComponentType =
5+
| "Button"
6+
| "Checkbox"
7+
| "Dropdown"
8+
| "Plot"
9+
| "Box"
10+
| "Typography";
511

612
export interface ComponentState {
713
type: ComponentType;
@@ -47,3 +53,8 @@ export interface PlotState extends ComponentState {
4753
export interface BoxState extends ContainerState {
4854
type: "Box";
4955
}
56+
57+
export interface TypographyState extends ComponentState {
58+
type: "Typography";
59+
text?: string;
60+
}

0 commit comments

Comments
 (0)