Skip to content

Commit fa2d04d

Browse files
chore: add id to GoabText
1 parent b1a39e3 commit fa2d04d

File tree

1 file changed

+66
-9
lines changed

1 file changed

+66
-9
lines changed

src/routes/components/Text.tsx

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from "react";
1+
import { useContext, useState } from "react";
22
import { ComponentBinding, Sandbox } from "@components/sandbox";
33
import {
44
ComponentProperties,
@@ -9,10 +9,12 @@ import { GoabText, GoabTab, GoabTabs, GoabBadge } from "@abgov/react-components"
99
import { DesignEmpty } from "@components/empty-states/design-empty/DesignEmpty.tsx";
1010
import { AccessibilityEmpty } from "@components/empty-states/accessibility-empty/AccessibilityEmpty.tsx";
1111
import { ExamplesEmpty } from "@components/empty-states/examples-empty/ExamplesEmpty.tsx";
12+
import { LanguageVersionContext } from "@contexts/LanguageVersionContext.tsx";
1213

1314
const FIGMA_LINK = "https://www.figma.com/design/3pb2IK8s2QUqWieH79KdN7/%E2%9D%96-Component-library-%7C-DDD?node-id=27301-303449";
1415

1516
export default function TextPage() {
17+
const { version } = useContext(LanguageVersionContext);
1618
const [textProps, setTextProps] = useState({});
1719

1820
const [textBindings, setTextBindings] = useState<ComponentBinding[]>([
@@ -57,8 +59,53 @@ export default function TextPage() {
5759
options: ["none", "3xs", "2xs", "xs", "s", "m", "l", "xl", "2xl", "3xl", "4xl"],
5860
value: "none",
5961
},
62+
{
63+
label: "Id",
64+
type: "string",
65+
name: "id",
66+
value: "",
67+
},
6068
]);
6169

70+
const oldComponentProperties: ComponentProperty[] = [
71+
{
72+
name: "tag",
73+
type: "h1 | h2 | h3 | h4 | h5 | span | div | p",
74+
description: "Sets the tag and text size.",
75+
defaultValue: "div"
76+
},
77+
{
78+
name: "size",
79+
type: "heading-xl | heading-l | heading-m | heading-s | heading-xs | body-l | body-m | body-s | body-xs",
80+
description: "Overrides the text size from the 'as' property."
81+
},
82+
{
83+
name: "maxWidth",
84+
type: "string",
85+
description: "Sets the max width.",
86+
defaultValue: "65ch",
87+
lang: "react",
88+
},
89+
{
90+
name: "maxwidth",
91+
type: "string",
92+
description: "Sets the max width.",
93+
defaultValue: "65ch",
94+
lang: "angular",
95+
},
96+
{
97+
name: "color",
98+
type: "primary | secondary",
99+
description: "Sets the text colour.",
100+
defaultValue: "primary"
101+
},
102+
{
103+
name: "mt,mr,mb,ml",
104+
type: "none | 3xs | 2xs | xs | s | m | l | xl | 2xl | 3xl | 4xl",
105+
description: "Apply margin to the top, right, bottom, and/or left of the component.",
106+
},
107+
];
108+
62109
const componentProperties: ComponentProperty[] = [
63110
{
64111
name: "tag",
@@ -72,17 +119,22 @@ export default function TextPage() {
72119
description: "Overrides the text size from the 'as' property."
73120
},
74121
{
75-
name: "maxWidth",
76-
type: "string",
77-
description: "Sets the max width.",
78-
defaultValue: "65ch"
122+
name: "maxWidth",
123+
type: "string",
124+
description: "Sets the max width.",
125+
defaultValue: "65ch"
79126
},
80-
{
127+
{
81128
name: "color",
82129
type: "primary | secondary",
83130
description: "Sets the text colour.",
84131
defaultValue: "primary"
85-
},
132+
},
133+
{
134+
name: "id",
135+
type: "string",
136+
description: "Sets the HTML id attribute on the text element.",
137+
},
86138
{
87139
name: "mt,mr,mb,ml",
88140
type: "none | 3xs | 2xs | xs | s | m | l | xl | 2xl | 3xl | 4xl",
@@ -108,13 +160,18 @@ export default function TextPage() {
108160
<GoabTabs initialTab={1}>
109161
<GoabTab heading="Code playground">
110162
<h2 id="component" style={{ display: "none" }}>Playground</h2>
111-
<Sandbox properties={textBindings} onChange={onSandboxChange}>
163+
<Sandbox
164+
properties={version === "new"
165+
? textBindings
166+
: textBindings.filter(b => b.name !== "id")}
167+
onChange={onSandboxChange}
168+
>
112169
<GoabText {...textProps}>
113170
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
114171
dolore magna aliqua.
115172
</GoabText>
116173
</Sandbox>
117-
<ComponentProperties properties={componentProperties} />
174+
<ComponentProperties oldProperties={oldComponentProperties} properties={componentProperties} />
118175
</GoabTab>
119176

120177
<GoabTab

0 commit comments

Comments
 (0)