From b97c88c2b023febc3eb1ebe7ea3e56a174488d4e Mon Sep 17 00:00:00 2001 From: Daniel Sil Date: Thu, 16 Jan 2025 17:34:00 +0100 Subject: [PATCH] chore: add playroom snippets --- packages/orbit-components/playroom.config.js | 2 +- .../orbit-components/playroom/snippets.ts | 39 ------- .../playroom/snippets/Accordion.ts | 56 +++++++++ .../playroom/snippets/BasicComponents.ts | 110 ++++++++++++++++++ .../playroom/snippets/Card.ts | 32 +++++ .../playroom/snippets/Layouts.ts | 83 +++++++++++++ .../playroom/snippets/VisualComponents.ts | 62 ++++++++++ .../playroom/snippets/index.ts | 16 +++ .../playroom/snippets/snippet.d.ts | 5 + 9 files changed, 365 insertions(+), 40 deletions(-) delete mode 100644 packages/orbit-components/playroom/snippets.ts create mode 100644 packages/orbit-components/playroom/snippets/Accordion.ts create mode 100644 packages/orbit-components/playroom/snippets/BasicComponents.ts create mode 100644 packages/orbit-components/playroom/snippets/Card.ts create mode 100644 packages/orbit-components/playroom/snippets/Layouts.ts create mode 100644 packages/orbit-components/playroom/snippets/VisualComponents.ts create mode 100644 packages/orbit-components/playroom/snippets/index.ts create mode 100644 packages/orbit-components/playroom/snippets/snippet.d.ts diff --git a/packages/orbit-components/playroom.config.js b/packages/orbit-components/playroom.config.js index 4679ef6138..0e03ff28bf 100644 --- a/packages/orbit-components/playroom.config.js +++ b/packages/orbit-components/playroom.config.js @@ -6,7 +6,7 @@ module.exports = { components: require.resolve("./playroomComponents.tsx"), outputPath: "./.playroom/playroom", frameComponent: "./playroom/FrameComponent.tsx", - snippets: "./playroom/snippets.ts", + snippets: "./playroom/snippets/index.ts", scope: "./playroom/scope.ts", port: 9000, openBrowser: false, diff --git a/packages/orbit-components/playroom/snippets.ts b/packages/orbit-components/playroom/snippets.ts deleted file mode 100644 index c287ae2ff2..0000000000 --- a/packages/orbit-components/playroom/snippets.ts +++ /dev/null @@ -1,39 +0,0 @@ -interface Snippet { - group: string; - name: string; - code: string; -} - -const snippets: Snippet[] = [ - { - group: "Basic Components", - name: "Button Primary", - code: ``, - }, - { - group: "Basic Components", - name: "Alert Info", - code: `This is an informational message`, - }, - { - group: "Forms", - name: "Input Field", - code: ``, - }, - { - group: "Layout", - name: "Card with Content", - code: ` - - - - Card Title - This is some content inside a card. - - - -`, - }, -]; - -export default snippets; diff --git a/packages/orbit-components/playroom/snippets/Accordion.ts b/packages/orbit-components/playroom/snippets/Accordion.ts new file mode 100644 index 0000000000..a6adac5013 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/Accordion.ts @@ -0,0 +1,56 @@ +const utils = `const [expandedSection, setExpandedSection] = React.useState("accordion-section-0");`; + +const code = ` +<> + {/* For the example to work as expected, you should also import the Accordion Utils before the return. */} + + setExpandedSection(String(id))}> + + This is a header label + This is a header label + + } + > + This is a content text + + + This is a header label + This is a header label + + } + > + This is a content text + + + This is a header label + This is a header label + + } + > + This is a content text + + + +`; + +export default [ + { + group: "Accordion", + name: "Basic Accordion", + code, + }, + { + group: "Accordion", + name: "Utils", + code: utils, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/BasicComponents.ts b/packages/orbit-components/playroom/snippets/BasicComponents.ts new file mode 100644 index 0000000000..5af07a68b6 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/BasicComponents.ts @@ -0,0 +1,110 @@ +const alert = `The message.`; + +const button = ``; + +const badge = `Content`; + +const buttonLink = `ButtonLink`; + +const badgeList = ` + + }> + You're departing from a different place + + } type="info" size="normal"> + You must collect and recheck your baggage + + +`; + +const breadcrumbs = ` + + Kiwi.com + 1. Level + 2. Level + 3. Level + +`; + +const buttonGroup = ` + + + }/>`; + +const heading = `Heading`; + +export default [ + { + group: "Alert", + code: alert, + }, + { + group: "Button", + code: button, + }, + { + group: "ButtonLink", + code: buttonLink, + }, + { + group: "ButtonGroup", + code: buttonGroup, + }, + { + group: "Badge", + code: badge, + }, + { + group: "BadgeList", + code: badgeList, + }, + { + group: "Breadcrumbs", + code: breadcrumbs, + }, + { + group: "Checkbox", + code: checkbox, + }, + { + group: "ChoiceGroup", + code: choiceGroup, + }, + { + group: "Collapse", + code: collapse, + }, + { + group: "Coupon", + code: coupon, + }, + { + group: "Dialog", + code: dialog, + }, + { + group: "Heading", + code: heading, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/Card.ts b/packages/orbit-components/playroom/snippets/Card.ts new file mode 100644 index 0000000000..733dc2792b --- /dev/null +++ b/packages/orbit-components/playroom/snippets/Card.ts @@ -0,0 +1,32 @@ +const basic = ``; + +const expandable = ` + + + Section content + + + Section content + + +`; + +export default [ + { + group: "Card", + name: "Basic Card", + code: basic, + }, + { + group: "Card", + name: "Expandable Card", + code: expandable, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/Layouts.ts b/packages/orbit-components/playroom/snippets/Layouts.ts new file mode 100644 index 0000000000..f0601fea52 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/Layouts.ts @@ -0,0 +1,83 @@ +const calloutBanner = ` +} size="small" type="secondary">Find a Room} + description="Select your accommodation from more than a million properties worldwide." + illustration={} + title="Rooms in Warsaw" +> + + }> + Up to 50% off. + + }> + From 3-star budget to 5-star luxury. + + + +`; + +const drawer = ` + + + + + Link 1 + + + Link 2 + + + Link 3 + + + + + + Sign out + + + +`; + +const horizontalScroll = ` + + {Array(...Array(10)).map((_, key) => ( + + +
+ {key} +
+
+
+ ))} + )} +
+`; + +export default [ + { + group: "CalloutBanner", + code: calloutBanner, + }, + { + group: "Drawer", + code: drawer, + }, + { + group: "HorizontalScroll", + code: horizontalScroll, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/VisualComponents.ts b/packages/orbit-components/playroom/snippets/VisualComponents.ts new file mode 100644 index 0000000000..bb37f4f4af --- /dev/null +++ b/packages/orbit-components/playroom/snippets/VisualComponents.ts @@ -0,0 +1,62 @@ +const airportIllustration = ``; + +const countryFlag = ``; + +const carrierLogo = ` + +`; + +const featureIcon = ``; + +const icon = ``; + +const illustration = ``; + +export default [ + { + group: "Airport Illustration", + code: airportIllustration, + }, + { + group: "Carrier Logo", + code: carrierLogo, + }, + { + group: "Country Flag", + code: countryFlag, + }, + { + group: "Feature Icon", + code: featureIcon, + }, + { + group: "Icon", + code: icon, + }, + { + group: "Illustration", + code: illustration, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/index.ts b/packages/orbit-components/playroom/snippets/index.ts new file mode 100644 index 0000000000..83e4d89bfc --- /dev/null +++ b/packages/orbit-components/playroom/snippets/index.ts @@ -0,0 +1,16 @@ +import type { Snippet } from "./snippet"; +import Accordion from "./Accordion"; +import VisualComponents from "./VisualComponents"; +import BasicComponents from "./BasicComponents"; +import Layouts from "./Layouts"; +import Card from "./Card"; + +const snippets: Snippet[] = [ + ...Accordion, + ...BasicComponents, + ...Card, + ...Layouts, + ...VisualComponents, +].sort((a, b) => a.group.localeCompare(b.group)); + +export default snippets; diff --git a/packages/orbit-components/playroom/snippets/snippet.d.ts b/packages/orbit-components/playroom/snippets/snippet.d.ts new file mode 100644 index 0000000000..a62de7b2f9 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/snippet.d.ts @@ -0,0 +1,5 @@ +export interface Snippet { + group: string; + name?: string; + code: string; +}