From 828dcb3a963aaa83c34e73d1ba762315ac314fda Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 7 Apr 2026 20:46:07 +0000 Subject: [PATCH] :sparkles: Add RawSvg component to @penpot/ui --- frontend/packages/ui/AGENTS.md | 9 ++- frontend/packages/ui/src/index.ts | 2 + .../lib/foundations/assets/RawSvg.module.scss | 8 +++ .../lib/foundations/assets/RawSvg.spec.tsx | 63 +++++++++++++++++++ .../lib/foundations/assets/RawSvg.stories.tsx | 36 +++++++++++ .../ui/src/lib/foundations/assets/RawSvg.tsx | 57 +++++++++++++++++ 6 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 frontend/packages/ui/src/lib/foundations/assets/RawSvg.module.scss create mode 100644 frontend/packages/ui/src/lib/foundations/assets/RawSvg.spec.tsx create mode 100644 frontend/packages/ui/src/lib/foundations/assets/RawSvg.stories.tsx create mode 100644 frontend/packages/ui/src/lib/foundations/assets/RawSvg.tsx diff --git a/frontend/packages/ui/AGENTS.md b/frontend/packages/ui/AGENTS.md index 529696d370..82d74b22f8 100644 --- a/frontend/packages/ui/AGENTS.md +++ b/frontend/packages/ui/AGENTS.md @@ -32,11 +32,15 @@ frontend/packages/ui/ │ │ └── IconButton.spec.tsx │ ├── example/ # Example component (reference) │ ├── foundations/ -│ │ ├── assets/ # Icon component +│ │ ├── assets/ # Icon, RawSvg components │ │ │ ├── Icon.tsx │ │ │ ├── Icon.module.scss │ │ │ ├── Icon.stories.tsx -│ │ │ └── Icon.spec.tsx +│ │ │ ├── Icon.spec.tsx +│ │ │ ├── RawSvg.tsx +│ │ │ ├── RawSvg.module.scss +│ │ │ ├── RawSvg.stories.tsx +│ │ │ └── RawSvg.spec.tsx │ │ └── typography/ # Text, Heading components + shared utilities │ └── product/ # Product-level components (e.g. Cta) ├── eslint.config.mjs # ESLint 9 flat config (TypeScript + React) @@ -56,6 +60,7 @@ Components are organised to mirror the CLJS source tree | `ds/foundations/typography/text.cljs` | `src/lib/foundations/typography/Text.tsx` | | `ds/foundations/typography/heading.cljs` | `src/lib/foundations/typography/Heading.tsx` | | `ds/foundations/assets/icon.cljs` | `src/lib/foundations/assets/Icon.tsx` | +| `ds/foundations/assets/raw_svg.cljs` | `src/lib/foundations/assets/RawSvg.tsx` | | `ds/product/cta.cljs` | `src/lib/product/Cta.tsx` | | `ds/buttons/button.cljs` | `src/lib/buttons/Button.tsx` | | `ds/buttons/icon_button.cljs` | `src/lib/buttons/IconButton.tsx` | diff --git a/frontend/packages/ui/src/index.ts b/frontend/packages/ui/src/index.ts index d483b274f1..57f74fa36c 100644 --- a/frontend/packages/ui/src/index.ts +++ b/frontend/packages/ui/src/index.ts @@ -13,6 +13,8 @@ export { Cta } from "./lib/product/Cta"; export type { CtaProps } from "./lib/product/Cta"; export { Icon, iconIds } from "./lib/foundations/assets/Icon"; export type { IconId, IconProps } from "./lib/foundations/assets/Icon"; +export { RawSvg, rawSvgIds } from "./lib/foundations/assets/RawSvg"; +export type { RawSvgId, RawSvgProps } from "./lib/foundations/assets/RawSvg"; export { Button } from "./lib/buttons/Button"; export type { ButtonProps, ButtonVariant } from "./lib/buttons/Button"; export { IconButton } from "./lib/buttons/IconButton"; diff --git a/frontend/packages/ui/src/lib/foundations/assets/RawSvg.module.scss b/frontend/packages/ui/src/lib/foundations/assets/RawSvg.module.scss new file mode 100644 index 0000000000..a07372ef46 --- /dev/null +++ b/frontend/packages/ui/src/lib/foundations/assets/RawSvg.module.scss @@ -0,0 +1,8 @@ +// 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 + +// RawSvg has no component-specific styles; all sizing and colour is +// controlled by the consumer via props (width, height, style, etc.). diff --git a/frontend/packages/ui/src/lib/foundations/assets/RawSvg.spec.tsx b/frontend/packages/ui/src/lib/foundations/assets/RawSvg.spec.tsx new file mode 100644 index 0000000000..3005792069 --- /dev/null +++ b/frontend/packages/ui/src/lib/foundations/assets/RawSvg.spec.tsx @@ -0,0 +1,63 @@ +// 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 { RawSvg, rawSvgIds } from "./RawSvg"; + +describe("RawSvg", () => { + it("should render successfully", () => { + const { baseElement } = render(