diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..47245f4ba --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "useTabs": true, + "jsxSingleQuote": true, + "singleQuote": true, + "singleAttributePerLine": true, + "printWidth": 120 +} diff --git a/website/blog/2022-03-03-adding-blocks-wpcli.md b/website/blog/2022-03-03-adding-blocks-wpcli.md index 918b25c43..186881c98 100644 --- a/website/blog/2022-03-03-adding-blocks-wpcli.md +++ b/website/blog/2022-03-03-adding-blocks-wpcli.md @@ -7,7 +7,7 @@ date: 2022-03-14 tags: [eightshift, boilerplate, wpcli, components, blocks] hide_table_of_contents: false --- -Although there are a few basic blocks available after creating a project, there are a lot more blocks available in the dev kit. However, you have to add them to your project using WP-CLI (the simplest method). To see the complete list of available components and blocks, visit our [Storybook](/devkit-components). +Although there are a few basic blocks available after creating a project, there are a lot more blocks available in the dev kit. However, you have to add them to your project using WP-CLI (the simplest method). To see the complete list of available components and blocks, visit our [Storybook](/components/legacy-component-docs). These can be used out-of-the-box, but also as a good starting point if you need similar blocks in your projects. It will also speed up your development time since you don't have to build everything from scratch. diff --git a/website/blog/2022-04-25-using-assets.md b/website/blog/2022-04-25-using-assets.md index 5a09c04c7..a0e4605e6 100644 --- a/website/blog/2022-04-25-using-assets.md +++ b/website/blog/2022-04-25-using-assets.md @@ -99,7 +99,7 @@ Here are some examples of icons available out-of-the-box in our Icon component: ## Using icons for editor and block options -When developing your blocks and adding new options, you may need to add icons to improve the user experience. We have many icons already available for use. You can see the full list in our [Storybook](/devkit-components) under `UI icons` and `Block icons` section. We already added the icon when adding a new Color Theme option for the Quote block. Here is the simplified version: +When developing your blocks and adding new options, you may need to add icons to improve the user experience. We have many icons already available for use. You can see the full list in our [Storybook](/components/legacy-component-docs) under `UI icons` and `Block icons` section. We already added the icon when adding a new Color Theme option for the Quote block. Here is the simplified version: ```jsx import { ColorPaletteCustom, IconLabel, icons } from '@eightshift/frontend-libs/scripts'; diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index ee587f398..a441ed459 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -1,10 +1,11 @@ -const {themes} = require('prism-react-renderer'); +const { themes } = require('prism-react-renderer'); const darkTheme = themes.dracula; module.exports = { title: 'Eightshift Development kit', - tagline: 'All the tools you need to start building a modern WordPress project, using all the latest front end development tools.', + tagline: + 'All the tools you need to start building a modern WordPress project, using all the latest front end development tools.', url: 'https://eightshift.com', baseUrl: '/', favicon: '/img/favicon.png', @@ -16,7 +17,7 @@ module.exports = { src: 'https://buttons.github.io/buttons.js', async: true, defer: true, - } + }, ], themeConfig: { navbar: { @@ -38,8 +39,8 @@ module.exports = { position: 'right', }, { - to: '/devkit-components/', - activeBasePath: 'devkit-components', + to: '/components/welcome', + activeBasePath: 'components', label: 'Components', position: 'right', }, @@ -107,7 +108,11 @@ module.exports = { appId: 'CWB1S6U3C4', apiKey: 'cbae3fc769aee256328548eff1e91c1c', indexName: 'infinum_eightshift', - startUrls: ['https://eightshift.com', 'https://eightshift.com/docs', 'https://eightshift.com/forms'], + startUrls: [ + 'https://eightshift.com', + 'https://eightshift.com/docs', + 'https://eightshift.com/forms', + ], contextualSearch: false, }, prism: { @@ -122,9 +127,9 @@ module.exports = { docs: { sidebar: { autoCollapseCategories: true, - } + }, }, - trailingSlash: false + trailingSlash: false, }, presets: [ [ @@ -146,7 +151,8 @@ module.exports = { }, blog: { blogTitle: 'Tutorials and articles about Eightshift development kit', - blogDescription: 'Tutorials and articles about Eightshift development kit', + blogDescription: + 'Tutorials and articles about Eightshift development kit', blogSidebarTitle: 'Latest posts', showReadingTime: true, postsPerPage: 9, @@ -168,6 +174,15 @@ module.exports = { sidebarPath: require.resolve('./sidebars-forms.js'), }, ], + [ + '@docusaurus/plugin-content-docs', + { + id: 'ui-components', + path: 'ui-components', + routeBasePath: 'components', + sidebarPath: require.resolve('./sidebars-components.js'), + }, + ], 'es-text-loader', ], customFields: { @@ -178,7 +193,7 @@ module.exports = { 'Gutenberg blocks', 'development kit', 'wordpress kit', - 'devkit' + 'devkit', ], image: 'img-why-boilerplate@2x.png', }, diff --git a/website/package-lock.json b/website/package-lock.json index 256764c41..4d5fd02c6 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@docusaurus/core": "^3.4.0", "@docusaurus/preset-classic": "^3.4.0", + "@eightshift/ui-components": "^1.2.0", "@infinum/docusaurus-theme": "^0.5.0", "@mdx-js/react": "^3.0.1", "@wp-playground/client": "^0.7.20", @@ -3180,6 +3181,21 @@ "node": ">=18.0" } }, + "node_modules/@eightshift/ui-components": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@eightshift/ui-components/-/ui-components-1.2.0.tgz", + "integrity": "sha512-hLA6be1CuC+XVEMyRE22DMxHUqL3KkG2s2KxQUvZ75yFt9iR1a4uyAttKM7MfpGdicn3hH939XicxWs9UszVlw==", + "dependencies": { + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-jsx-parser": "^1.29.0", + "svg-to-jsx-string": "^0.1.1" + }, + "peerDependencies": { + "react": "^18.3.1", + "react-dom": "^18.3.1" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -4931,6 +4947,16 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/jsdom": { + "version": "16.2.15", + "resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-16.2.15.tgz", + "integrity": "sha512-nwF87yjBKuX/roqGYerZZM0Nv1pZDMAT5YhOHYeM/72Fic+VEqJh4nyoqoapzJnW3pUlfxPY5FhgsJtM+dRnQQ==", + "dependencies": { + "@types/node": "*", + "@types/parse5": "^6.0.3", + "@types/tough-cookie": "*" + } + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -4985,6 +5011,11 @@ "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.2.tgz", "integrity": "sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==" }, + "node_modules/@types/parse5": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@types/parse5/-/parse5-6.0.3.tgz", + "integrity": "sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==" + }, "node_modules/@types/prettier": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", @@ -5024,6 +5055,26 @@ "csstype": "^3.0.2" } }, + "node_modules/@types/react-dom": { + "version": "17.0.25", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.25.tgz", + "integrity": "sha512-urx7A7UxkZQmThYA4So0NelOVjx3V4rNFVJwp0WZlbIK5eM4rNJDiN3R/E9ix0MBh6kAEojk/9YL+Te6D9zHNA==", + "optional": true, + "dependencies": { + "@types/react": "^17" + } + }, + "node_modules/@types/react-dom/node_modules/@types/react": { + "version": "17.0.80", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.80.tgz", + "integrity": "sha512-LrgHIu2lEtIo8M7d1FcI3BdwXWoRQwMoXOZ7+dPTW0lYREjmlHl3P0U1VD0i/9tppOuv8/sam7sOjx34TxSFbA==", + "optional": true, + "dependencies": { + "@types/prop-types": "*", + "@types/scheduler": "^0.16", + "csstype": "^3.0.2" + } + }, "node_modules/@types/react-router": { "version": "5.1.20", "resolved": "https://registry.npmjs.org/@types/react-router/-/react-router-5.1.20.tgz", @@ -5074,6 +5125,12 @@ "@types/node": "*" } }, + "node_modules/@types/scheduler": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", + "integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==", + "optional": true + }, "node_modules/@types/semver": { "version": "7.5.8", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", @@ -5119,6 +5176,11 @@ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==" }, + "node_modules/@types/tough-cookie": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz", + "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==" + }, "node_modules/@types/trusted-types": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", @@ -18848,6 +18910,38 @@ "react": "^16.13.1 || ^17.0.0 || ^18.0.0" } }, + "node_modules/react-jsx-parser": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/react-jsx-parser/-/react-jsx-parser-1.29.0.tgz", + "integrity": "sha512-u0svZd0UsPffRrIK0sTbox54jhEbTmg6ED9ob5FQahp1DeOpd2Rq+KiSTIFNYkZUL+WZi4Ntia/Oj5T4lDJafQ==", + "hasInstallScript": true, + "dependencies": { + "@types/jsdom": "^16.2.6", + "acorn": "^8.0.5", + "acorn-jsx": "^5.3.1", + "browserslist": "^4.14.5", + "core-js": "^3.8.3" + }, + "optionalDependencies": { + "@types/react": "^17.0.1", + "@types/react-dom": "^17.0.0" + }, + "peerDependencies": { + "react": ">=17", + "react-dom": ">=17" + } + }, + "node_modules/react-jsx-parser/node_modules/@types/react": { + "version": "17.0.80", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.80.tgz", + "integrity": "sha512-LrgHIu2lEtIo8M7d1FcI3BdwXWoRQwMoXOZ7+dPTW0lYREjmlHl3P0U1VD0i/9tppOuv8/sam7sOjx34TxSFbA==", + "optional": true, + "dependencies": { + "@types/prop-types": "*", + "@types/scheduler": "^0.16", + "csstype": "^3.0.2" + } + }, "node_modules/react-loadable": { "name": "@docusaurus/react-loadable", "version": "6.0.0", @@ -22305,6 +22399,11 @@ "resolved": "https://registry.npmjs.org/svg-parser/-/svg-parser-2.0.4.tgz", "integrity": "sha512-e4hG1hRwoOdRb37cIMSgzNsxyzKfayW6VOflrwvR+/bzrkyxY/31WkbgnQpgtrNp1SdpJvpUAGTa/ZoiPNDuRQ==" }, + "node_modules/svg-to-jsx-string": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/svg-to-jsx-string/-/svg-to-jsx-string-0.1.1.tgz", + "integrity": "sha512-iZ6vpKQkZxX2TPnlWmb/GuSV9Msjfp7YVgyUnmMOEl9IUw8ilNqNBny/T/2tt6ctV1EqaDvOs5f7X0LrTIkqtA==" + }, "node_modules/svgo": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/svgo/-/svgo-3.3.2.tgz", diff --git a/website/package.json b/website/package.json index 148f0e913..723ce5f82 100644 --- a/website/package.json +++ b/website/package.json @@ -34,6 +34,7 @@ "dependencies": { "@docusaurus/core": "^3.4.0", "@docusaurus/preset-classic": "^3.4.0", + "@eightshift/ui-components": "^1.2.0", "@infinum/docusaurus-theme": "^0.5.0", "@mdx-js/react": "^3.0.1", "@wp-playground/client": "^0.7.20", diff --git a/website/sidebars-components.js b/website/sidebars-components.js new file mode 100644 index 000000000..de9103f4b --- /dev/null +++ b/website/sidebars-components.js @@ -0,0 +1,117 @@ +module.exports = { + components: [ + 'welcome', + { + type: 'category', + label: 'Eightshift UI components', + items: [ + 'es-ui-components/getting-started', + { + type: 'category', + label: 'Icons', + items: ['es-ui-components/ui-icons', 'es-ui-components/block-icons'], + }, + 'es-ui-components/base-control', + { + type: 'category', + label: 'Simple components', + items: [ + 'es-ui-components/rich-label', + 'es-ui-components/button', + 'es-ui-components/notice', + 'es-ui-components/menu', + 'es-ui-components/tooltip', + 'es-ui-components/number-picker', + 'es-ui-components/placeholders', + 'es-ui-components/link-input', + 'es-ui-components/input-field', + 'es-ui-components/slider', + ], + }, + { + type: 'category', + label: 'Toggles and toggle-related', + items: [ + 'es-ui-components/toggle-switch', + 'es-ui-components/checkbox', + 'es-ui-components/radio-button', + 'es-ui-components/toggle-button', + 'es-ui-components/component-toggle', + ], + }, + { + type: 'category', + label: 'Layout components', + items: [ + 'es-ui-components/spacer', + 'es-ui-components/stacks', + 'es-ui-components/tabs', + 'es-ui-components/repeater', + 'es-ui-components/draggable-list', + ], + }, + { + type: 'category', + label: 'Reveal components', + items: [ + 'es-ui-components/triggered-popover', + 'es-ui-components/animated-visibility', + 'es-ui-components/expandable', + ], + }, + { + type: 'category', + label: 'Responsive components', + items: [ + 'es-ui-components/responsive', + 'es-ui-components/breakpoint-preview', + 'es-ui-components/responsive-preview', + ], + }, + { + type: 'category', + label: 'Selection', + items: [ + 'es-ui-components/column-config-slider', + 'es-ui-components/matrix-align', + { + type: 'category', + label: 'Select', + items: [ + 'es-ui-components/select', + 'es-ui-components/multi-select', + 'es-ui-components/async-select', + 'es-ui-components/async-multi-select', + 'es-ui-components/select-customization', + ], + }, + ], + }, + + { + type: 'category', + label: 'Colors and gradients', + items: [ + 'es-ui-components/color-picker', + 'es-ui-components/solid-color-picker', + 'es-ui-components/gradient-editor', + 'es-ui-components/color-swatch', + ], + }, + { + type: 'category', + label: 'Panels', + items: ['es-ui-components/container-panel', 'es-ui-components/options-panel'], + }, + ], + }, + { + type: 'category', + label: 'Frontend libs components', + items: [ + 'fe-libs-components/introduction' + ], + }, + 'legacy-component-docs', + ], +}; diff --git a/website/src/theme/styles.css b/website/src/theme/styles.css index a555d9201..ae7cdbb2f 100644 --- a/website/src/theme/styles.css +++ b/website/src/theme/styles.css @@ -1,35 +1,38 @@ @import url('https://use.typekit.net/baz1roy.css'); +@import '~@eightshift/ui-components/dist/assets/fonts.css'; +@import '~@eightshift/ui-components/dist/assets/style.css'; + .esd-full-fixed { position: fixed; inset: 0; } - -progress { - appearance: none; +.esd-hide-bg-on-hover.es-uic-bg-violet-50:hover, +.esd-hide-bg-on-hover:hover .es-uic-bg-violet-50, +.esd-hide-bg-on-hover.es-uic-bg-gray-50:hover, +.esd-hide-bg-on-hover:hover .es-uic-bg-gray-50 { + --tw-bg-opacity: 0 !important; } -progress::-webkit-progress-bar { - background-color: white; - border-radius: 10rem; - border: 1px solid var(--ifm-color-gray-400); - - height: 0.5rem; +.esd-white-space-pre { + white-space: break-spaces; } -progress::-webkit-progress-value { - background-color: #D8262C; - border-radius: 10rem; +.esd-icon-showcase-button { + inline-size: 3.25rem !important; + block-size: 3.25rem !important; - height: 0.5rem; - - transition: 0.5s inline-size ease-out; + svg { + inline-size: 1.5rem !important; + block-size: 1.5rem !important; + } } -progress[value]::-moz-progress-bar { - background-color: #D8262C; - border-radius: 10rem; - height: 0.5rem; +.esd-legacy-docs-iframe { + min-inline-size: 64vw; + + border: 1px solid #D1D5DB !important; + border-radius: 0.5rem !important; } diff --git a/website/ui-components/components/component-showcase.js b/website/ui-components/components/component-showcase.js new file mode 100644 index 000000000..bd9d1e2a9 --- /dev/null +++ b/website/ui-components/components/component-showcase.js @@ -0,0 +1,43 @@ +import { useState, useRef } from 'react'; +import { Button } from '@eightshift/ui-components'; +import { clsx } from 'clsx'; + +export const ComponentShowcase = ({ + children, + defaultValue, + className, + fitWidth = false, + resettable = false, + preContent, +}) => { + const [data, setData] = useState(defaultValue); + const ref = useRef(); + + return ( +
+
+ {typeof children === 'function' && children(data, setData)} + {typeof children !== 'function' && children} +
+ +
+ {preContent && preContent(data, setData, ref)} + {resettable && ( + + )} +
+
+ ); +}; diff --git a/website/src/pages/devkit-components.js b/website/ui-components/components/legacy-playground.js similarity index 74% rename from website/src/pages/devkit-components.js rename to website/ui-components/components/legacy-playground.js index 3a0f39fd9..88863f5f3 100644 --- a/website/src/pages/devkit-components.js +++ b/website/ui-components/components/legacy-playground.js @@ -1,13 +1,7 @@ import React, { useEffect, useRef, useState } from 'react'; -import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; -import useBaseUrl from '@docusaurus/useBaseUrl'; -import Layout from '@theme/Layout'; import { startPlaygroundWeb, installTheme, wpCLI } from '@wp-playground/client'; -export default function DevKitComponents() { - const context = useDocusaurusContext(); - const { siteConfig = {} } = context; - +export const LegacyComponentShowcase = () => { const [isLoading, setIsLoading] = useState(true); const [loadingStep, setLoadingStep] = useState('Initializing'); const [loadingProgress, setLoadingProgress] = useState(null); @@ -22,9 +16,7 @@ export default function DevKitComponents() { php: '8.3', wp: '6.4', }, - phpExtensionBundles: [ - 'kitchen-sink' - ], + phpExtensionBundles: ['kitchen-sink'], features: { networking: true, }, @@ -33,9 +25,9 @@ export default function DevKitComponents() { { step: 'login', username: 'admin', - password: 'password' + password: 'password', }, - ] + ], }, sapiName: 'cli', }); @@ -49,8 +41,8 @@ export default function DevKitComponents() { headers: { 'Content-Type': 'application/octet-stream', }, - credentials: 'include' - }) + credentials: 'include', + }); setLoadingProgress(33); setLoadingStep('Unpacking theme'); @@ -86,7 +78,9 @@ export default function DevKitComponents() { }); // WP playground currently has an issue that pollutes the WP-CLI output, so --porcelain isn't of much help here unfortunately. - const addedPostId = wpCliOutput.substring(wpCliOutput.indexOf('Created post ') + 13, wpCliOutput.lastIndexOf('.')).trim(); + const addedPostId = wpCliOutput + .substring(wpCliOutput.indexOf('Created post ') + 13, wpCliOutput.lastIndexOf('.')) + .trim(); setLoadingStep('Finalizing'); setLoadingProgress(92); @@ -105,29 +99,26 @@ export default function DevKitComponents() { const iframeRef = useRef(null); return ( - +