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: `Click me`, - }, - { - 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. - Learn More - - -`, - }, -]; - -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..5fb93aaf83 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/BasicComponents.ts @@ -0,0 +1,344 @@ +const alert = `The message.`; + +const button = `Primary 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 = ` + + Button + }/> + +`; + +const checkbox = ``; + +const choiceGroup = ` + + + + +`; + +const collapse = `Collapsed content`; + +const coupon = `CODE`; + +const dialog = ` +Log out}/>`; + +const heading = `Heading`; + +const linkList = ` + + + Flight 1 + + + Flight 2 + + + Flight 3 + + +`; + +const list = ` + + + 24,000 locations around the globe + + + Lowest price car rental in Warsaw + + + From 3 star budget to 5 star luxury + + +`; + +const listChoice = ` +<> + } + selectable + /> + } + selectable + /> +> +`; + +const loading = ``; + +const notificationBadge = `10`; + +const pagination = ` + +`; + +const popover = ` + + Lorem ipsum + +} +> + } + > + Open popover + + +`; + +const radio = ``; + +const seat = ``; + +const segmentedSwitch = ` + + + +`; + +const separator = ``; + +const skeleton = ``; + +const socialButton = ``; + +const stepper = ``; + +const stopoverArrow = ``; + +const switchComponent = `} />`; + +const tag = ` +} + type="colored" + onRemove={() => {}} +> + Passengers + +`; + +const text = `Text`; + +const textLink = ` +} + onClick={() => {}} +> + Link text + +`; + +const timeline = ` + + + + + + +`; + +const tooltip = ` + + + Tooltip trigger + + +`; + +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, + }, + { + group: "LinkList", + code: linkList, + }, + { + group: "List", + code: list, + }, + { + group: "ListChoice", + code: listChoice, + }, + { + group: "Loading", + code: loading, + }, + { + group: "NotificationBadge", + code: notificationBadge, + }, + { + group: "Pagination", + code: pagination, + }, + { + group: "Popover", + code: popover, + }, + { + group: "Radio", + code: radio, + }, + { + group: "Seat", + code: seat, + }, + { + group: "SegmentedSwitch", + code: segmentedSwitch, + }, + { + group: "Separator", + code: separator, + }, + { + group: "Skeleton", + code: skeleton, + }, + { + group: "SocialButton", + code: socialButton, + }, + { + group: "Stepper", + code: stepper, + }, + { + group: "StopoverArrow", + code: stopoverArrow, + }, + { + group: "Switch", + code: switchComponent, + }, + { + group: "Tag", + code: tag, + }, + { + group: "Text", + code: text, + }, + { + group: "TextLink", + code: textLink, + }, + { + group: "Timeline", + code: timeline, + }, + { + group: "Tooltip", + code: tooltip, + }, +]; 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/Inputs.ts b/packages/orbit-components/playroom/snippets/Inputs.ts new file mode 100644 index 0000000000..10fba42fe0 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/Inputs.ts @@ -0,0 +1,199 @@ +const basic = ``; + +const withError = ` + + } + suffix={} size="normal"/>} + /> +`; + +const inputFile = ` + + +`; + +const inputGroup = ` + + + + + +`; + +const inputSelect = ` +, + title: 'Euro', + value: 'EUR' + }, + { + group: 'Popular', + prefix: , + title: 'US Dollar', + value: 'USD' + }, + { + group: 'Popular', + prefix: , + title: 'Pound Sterling', + value: 'GBP' + }, + { + prefix: , + title: 'Australian Dollar', + value: 'AUD' + }, + { + prefix: , + title: 'Brazilian Real', + value: 'BRL' + }, + { + prefix: , + title: 'Czech Koruna', + value: 'CZK' + } + ]} + placeholder="Select currency" + showAll +/> +`; + +const select = ` +} +/> +`; + +const textarea = ` + +`; + +export default [ + { + group: "InputField", + name: "Basic InputField", + code: basic, + }, + { + group: "InputField", + name: "InputField with Error", + code: withError, + }, + { + group: "InputFile", + code: inputFile, + }, + { + group: "InputGroup", + code: inputGroup, + }, + { + group: "InputSelect", + code: inputSelect, + }, + { + group: "Select", + code: select, + }, + { + group: "Textarea", + code: textarea, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/Layouts.ts b/packages/orbit-components/playroom/snippets/Layouts.ts new file mode 100644 index 0000000000..1c15b8ff19 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/Layouts.ts @@ -0,0 +1,483 @@ +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} + + + + ))} + )} + +`; + +const itinerary = ` + + + + + + } + type="warning" + > + Hidden city hack: This itinerary finishes in New York + (United States), but you’ll get off during the + layover. + + }> + Check travel document requirements for all + destinations, including passport, visa and COVID-19 + documents. + + } + > + You can’t bring checked baggage. + + + + + } + > + + , + name: "Carrier", + value: "HiFly", + }, + { + icon: , + name: "Connection number", + value: "TP 8345", + }, + ], + title: "Connection Info", + }, + { + items: [ + { + icon: , + name: "Seat pitch", + value: "76cm", + }, + { + icon: , + name: "Seat width", + value: "43cm", + }, + { + icon: , + name: "Seat recline", + value: "7cm", + }, + { + icon: , + name: "Audio & video on demand", + value: "No", + }, + { + icon: , + name: "In-seat power", + value: "No", + }, + { + icon: , + name: "Wi-Fi on board", + value: "No", + }, + ], + title: "Seating Info", + }, + ]} + duration="2h 10m" + summary={ + + HiFly + + } + /> + + + + + +`; + +const modal = ` + + } + title="Enjoy something to eat while you fly" + /> + + + + Outbound + + + + Edit + + } + expandable + noSeparator + title={ + + + + Sat, Mar 31 Trip length: 1h55m + + + London LHR + + Prague PRG + + + + } + /> + + Edit + + } + expandable + title={ + + + + Sat, Mar 31 Trip length: 1h55m + + + London LHR + + Prague PRG + + + + } + /> + + + + + + + INBOUND + + + + Edit + + } + expandable + title={ + + + + Sat, Mar 31 Trip length: 1h55m + + + London LHR + + Prague PRG + + + + } + /> + + Edit + + } + expandable + title={ + + + + Sat, Mar 31 Trip length: 1h55m + + + London LHR + + Prague PRG + + + + } + /> + + + + + } type="secondary"> + Back + + Proceed to Payment (23.98€) + + +`; + +const navigationBar = ` + + } + type="secondary" + > + Flights + + + } + type="secondary" + /> + } + type="secondary" + /> + + + +`; + +const table = ` + + + + + lorem ipsum + + + lorem ipsum + + + lorem ipsum + + + + + + + lorem ipsum + + + lorem ipsum + + + lorem ipsum + + + + + lorem ipsum + + + lorem ipsum + + + lorem ipsum + + + + +`; + +const tabs = ` + + + + Tab 1 + + + Tab 2 + + + Tab 3 + + + Tab 4 + + + + + Tab 1 content + + + Tab 2 content + + + Tab 3 content + + + Tab 4 content + + + +`; + +const wizard = ` + + + + + + + + + +`; + +export default [ + { + group: "CalloutBanner", + code: calloutBanner, + }, + { + group: "Drawer", + code: drawer, + }, + { + group: "HorizontalScroll", + code: horizontalScroll, + }, + { + group: "Itinerary", + code: itinerary, + }, + { + group: "Modal", + code: modal, + }, + { + group: "NavigationBar", + code: navigationBar, + }, + { + group: "Table", + code: table, + }, + { + group: "Tabs", + code: tabs, + }, + { + group: "Wizard", + code: wizard, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/Slider.ts b/packages/orbit-components/playroom/snippets/Slider.ts new file mode 100644 index 0000000000..6d2db7075e --- /dev/null +++ b/packages/orbit-components/playroom/snippets/Slider.ts @@ -0,0 +1,65 @@ +const basic = ` + +`; + +const withHistogram = ` + + + +`; + +export default [ + { + group: "Slider", + name: "Basic Slider", + code: basic, + }, + { + group: "Slider", + name: "Slider with Histogram", + code: withHistogram, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/Tile.ts b/packages/orbit-components/playroom/snippets/Tile.ts new file mode 100644 index 0000000000..2a2d7cfbd5 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/Tile.ts @@ -0,0 +1,82 @@ +const basic = ` +} + onClick={() => {}} +/> +`; + +const expandable = ` +} + header={ + + + + + Mr. Someone + + + + + + You + + + } +> + Expanded content + +`; + +const tileGroup = ` + + } + > + Expanded content + + } + > + Expanded content + + } + > + Expanded content + + } + > + Expanded content + + +`; + +export default [ + { + group: "Tile", + name: "Basic Tile", + code: basic, + }, + { + group: "Tile", + name: "Expandable Tile", + code: expandable, + }, + { + group: "TileGroup", + code: tileGroup, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/Toast.ts b/packages/orbit-components/playroom/snippets/Toast.ts new file mode 100644 index 0000000000..bda83a7360 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/Toast.ts @@ -0,0 +1,23 @@ +const utils = `const toast = () => createToast("Toast message", { icon: });`; + +const code = ` +<> + {/* For the example to work as expected, you should also import the Toast Utils before the return. */} + + Add toast + +> +`; + +export default [ + { + group: "Toast", + name: "Utils", + code: utils, + }, + { + group: "Toast", + name: "Toast", + code, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/VisualComponents.ts b/packages/orbit-components/playroom/snippets/VisualComponents.ts new file mode 100644 index 0000000000..0a92a58ef2 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/VisualComponents.ts @@ -0,0 +1,79 @@ +const airportIllustration = ``; + +const countryFlag = ``; + +const carrierLogo = ` + +`; + +const featureIcon = ``; + +const icon = ``; + +const illustration = ``; + +const serviceLogo = ``; + +const smartPassIllustration = ` +`; + +export default [ + { + group: "AirportIllustration", + code: airportIllustration, + }, + { + group: "CarrierLogo", + code: carrierLogo, + }, + { + group: "CountryFlag", + code: countryFlag, + }, + { + group: "FeatureIcon", + code: featureIcon, + }, + { + group: "Icon", + code: icon, + }, + { + group: "Illustration", + code: illustration, + }, + { + group: "ServiceLogo", + code: serviceLogo, + }, + { + group: "SmartPassIllustration", + code: smartPassIllustration, + }, +]; diff --git a/packages/orbit-components/playroom/snippets/index.ts b/packages/orbit-components/playroom/snippets/index.ts new file mode 100644 index 0000000000..08b111e316 --- /dev/null +++ b/packages/orbit-components/playroom/snippets/index.ts @@ -0,0 +1,24 @@ +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"; +import Inputs from "./Inputs"; +import Slider from "./Slider"; +import Tile from "./Tile"; +import Toast from "./Toast"; + +const snippets: Snippet[] = [ + ...Accordion, + ...BasicComponents, + ...Card, + ...Inputs, + ...Layouts, + ...Slider, + ...Tile, + ...Toast, + ...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; +}