From ee7bb5589db276dbbfe7b1e40c03565a555cf6dd Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 7 Apr 2026 22:32:53 +0000 Subject: [PATCH] :sparkles: Add Label component to @penpot/ui --- frontend/packages/ui/src/index.ts | 2 + .../lib/controls/utilities/Label.module.scss | 32 ++++++++ .../src/lib/controls/utilities/Label.spec.tsx | 81 +++++++++++++++++++ .../lib/controls/utilities/Label.stories.tsx | 35 ++++++++ .../ui/src/lib/controls/utilities/Label.tsx | 41 ++++++++++ 5 files changed, 191 insertions(+) create mode 100644 frontend/packages/ui/src/lib/controls/utilities/Label.module.scss create mode 100644 frontend/packages/ui/src/lib/controls/utilities/Label.spec.tsx create mode 100644 frontend/packages/ui/src/lib/controls/utilities/Label.stories.tsx create mode 100644 frontend/packages/ui/src/lib/controls/utilities/Label.tsx diff --git a/frontend/packages/ui/src/index.ts b/frontend/packages/ui/src/index.ts index 5043d4c638..3e08e6d831 100644 --- a/frontend/packages/ui/src/index.ts +++ b/frontend/packages/ui/src/index.ts @@ -40,3 +40,5 @@ export type { SwatchGradientStop, SwatchSize, } from "./lib/utilities/Swatch"; +export { Label } from "./lib/controls/utilities/Label"; +export type { LabelProps } from "./lib/controls/utilities/Label"; diff --git a/frontend/packages/ui/src/lib/controls/utilities/Label.module.scss b/frontend/packages/ui/src/lib/controls/utilities/Label.module.scss new file mode 100644 index 0000000000..e407e54ee2 --- /dev/null +++ b/frontend/packages/ui/src/lib/controls/utilities/Label.module.scss @@ -0,0 +1,32 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. +// +// Copyright (c) KALEIDOS INC + +@use "../../_ds/typography.scss" as t; + +.label { + --label-color: var(--color-foreground-primary); + --label-optional-color: var(--color-foreground-secondary); + + @include t.use-typography("body-small"); + + color: var(--label-color); + display: flex; + gap: var(--sp-xs); + align-items: center; +} + +.label-text, +.label-optional { + line-height: inherit; +} + +.label-text { + color: var(--label-color); +} + +.label-optional { + color: var(--label-optional-color); +} diff --git a/frontend/packages/ui/src/lib/controls/utilities/Label.spec.tsx b/frontend/packages/ui/src/lib/controls/utilities/Label.spec.tsx new file mode 100644 index 0000000000..8648ba8207 --- /dev/null +++ b/frontend/packages/ui/src/lib/controls/utilities/Label.spec.tsx @@ -0,0 +1,81 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. +// +// Copyright (c) KALEIDOS INC + +import { render } from "@testing-library/react"; +import { Label } from "./Label"; + +describe("Label", () => { + it("should render successfully", () => { + const { baseElement } = render(); + expect(baseElement).toBeTruthy(); + }); + + it("should render a