diff --git a/packages/react-selectors/README.md b/packages/react-selectors/README.md new file mode 100644 index 00000000..fd7348b2 --- /dev/null +++ b/packages/react-selectors/README.md @@ -0,0 +1,11 @@ +# `@wpmudev/react-selectors` + +> TODO: description + +## Usage + +``` +const reactSelectors = require('@wpmudev/react-selectors'); + +// TODO: DEMONSTRATE API +``` diff --git a/packages/react-selectors/__tests__/react-selectors.test.js b/packages/react-selectors/__tests__/react-selectors.test.js new file mode 100644 index 00000000..aecaee3b --- /dev/null +++ b/packages/react-selectors/__tests__/react-selectors.test.js @@ -0,0 +1,7 @@ +'use strict'; + +const reactSelectors = require('..'); + +describe('@wpmudev/react-selectors', () => { + it('needs tests'); +}); diff --git a/packages/react-selectors/docs/react-selectors-demo.stories.js b/packages/react-selectors/docs/react-selectors-demo.stories.js new file mode 100644 index 00000000..f7bc00f4 --- /dev/null +++ b/packages/react-selectors/docs/react-selectors-demo.stories.js @@ -0,0 +1,81 @@ +import React from "react"; +import { Selectors } from "../lib/react-selectors"; + +export default { + title: "Components/Selectors", + component: Selectors, + parameters: { + actions: { + disabled: true, + }, + notes: { + disabled: true, + }, + }, +}; + +export const demo = args => ; +demo.storyName = 'Demo'; +demo.args = { + name: 'selectors', + columns: 'three', + content: [ + { + id: "unique-id-1", + label: "Element text", + labelId: "label-id-1", + icon: "info", + }, + { + id: "unique-id-2", + label: "Element text", + labelId: "label-id-2", + icon: "info", + }, + { + id: "unique-id-3", + label: "Element text", + labelId: "label-id-3", + icon: "info", + disabled: true, + isPro: true, + }, + { + id: "unique-id-4", + label: "Element text", + labelId: "label-id-4", + icon: "info", + } + ], +}; +demo.argTypes = { + name: { + description: "Name of the selectors radio group.", + table: { + type: { summary: "string" }, + }, + control: { + type: 'text', + }, + }, + columns: { + description: "Number of columns or items in one row.", + table: { + type: { summary: "string" }, + }, + control: { + type: 'select', + options: ['one', 'two', 'three', 'four', 'five'], + }, + }, + content: { + description: "Items in selectors where each item is an object with the appropriate properties.", + + table: { + type: { summary: "array" }, + }, + control: { + type: 'array', + }, + } +}; \ No newline at end of file diff --git a/packages/react-selectors/docs/react-selectors-layouts.stories.js b/packages/react-selectors/docs/react-selectors-layouts.stories.js new file mode 100644 index 00000000..f5957595 --- /dev/null +++ b/packages/react-selectors/docs/react-selectors-layouts.stories.js @@ -0,0 +1,250 @@ +import React from 'react'; +import { Selectors } from '../lib/react-selectors'; + +export default { + title: 'Components/Selectors/Layouts', + component: Selectors, + parameters: { + actions: { + disabled: true, + }, + controls: { + disabled: true, + }, + notes: { + disabled: true, + }, + previewTabs: { + 'storybook/docs/panel': { + hidden: true, + }, + }, + }, + decorators: [ + ( Story ) => ( +
+
+ +
+
+ ), + ], +}; + +const StoryTitle = ({ children }) => { + const customStyles = { + margin: 0, + marginBottom: 10 + 'px', + color: '#333', + fontSize: 14 + 'px', + lineHeight: 22 + 'px', + }; + + return ( +

{ children }

+ ); +} + +const StoryDescription = ({ children }) => { + const customStyles = { + margin: 0, + marginBottom: 10 + 'px', + }; + + return ( +

+ { children } +

+ ); +} + +const StoryCode = ({ spaceTop = 5, spaceBottom = 20, children }) => { + const customStyles = { + display: 'block', + margin: 0, + marginTop: spaceTop + 'px', + marginBottom: spaceBottom + 'px', + padding: 5 + 'px ' + 10 + 'px', + }; + + return ( + { children } + ); +} + +const StorySection = ({ title, description, code, code2, isDefault = false, isLast = false, children }) => { + return ( + <> + { title && '' !== title && ( + { title }{ isDefault && ( + + )} + )} + { description && '' !== description && ( + { description } + )} + { code && '' !== code && ( + { code } + )} + { code2 && '' !== code2 && ( + { code2 } + )} + { children } + { !isLast &&
} + + ); +} + +const content = [ + { + id: "unique-id-1", + label: "Auto Col", + labelId: "label-id-1", + vertical: true, + }, + { + id: "unique-id-2", + label: "Auto Col", + labelId: "label-id-2", + vertical: true, + }, + { + id: "unique-id-3", + label: "Auto Col", + labelId: "label-id-3", + vertical: true, + }, + { + id: "unique-id-4", + label: "Auto Col", + labelId: "label-id-4", + vertical: true, + }, + { + id: "unique-id-5", + label: "Auto Col", + labelId: "label-id-5", + vertical: true, + }, +]; + +const oneCol = [ + { + id: "one-unique-id-1", + label: "One Column", + labelId: "one-label-id-1", + vertical: true, + }, + { + id: "one-unique-id-2", + label: "One Column", + labelId: "one-label-id-2", + vertical: true, + }, + { + id: "one-unique-id-3", + label: "One Column", + labelId: "one-label-id-3", + vertical: true, + }, + { + id: "one-unique-id-4", + label: "One Column", + labelId: "one-label-id-4", + vertical: true, + }, + { + id: "one-unique-id-5", + label: "One Column", + labelId: "one-label-id-5", + vertical: true, + }, + { + id: "one-unique-id-6", + label: "One Column", + labelId: "one-label-id-6", + vertical: true, + }, +]; + +export const auto = () => { + return ( + + + + ); +}; +auto.storyName = 'Auto Width'; + +export const one = () => { + return ( + + + + ); +}; +one.storyName = '1 Column'; + +export const two = () => { + return ( + + + + ); +}; +two.storyName = '2 Column'; + +export const three = () => { + return ( + + + + ); +}; +three.storyName = '3 Column'; + +export const four = () => { + return ( + + + + ); +}; +four.storyName = '4 Column'; + +export const five = () => { + return ( + + + + ); +}; +five.storyName = '5 Column'; diff --git a/packages/react-selectors/docs/react-selectors-modifiers.stories.js b/packages/react-selectors/docs/react-selectors-modifiers.stories.js new file mode 100644 index 00000000..ed705069 --- /dev/null +++ b/packages/react-selectors/docs/react-selectors-modifiers.stories.js @@ -0,0 +1,318 @@ +import React from 'react'; +import { Selectors } from '../lib/react-selectors'; + +export default { + title: 'Components/Selectors/Design', + component: Selectors, + parameters: { + actions: { + disabled: true, + }, + controls: { + disabled: true, + }, + notes: { + disabled: true, + }, + previewTabs: { + 'storybook/docs/panel': { + hidden: true, + }, + }, + }, + decorators: [ + ( Story ) => ( +
+
+ +
+
+ ), + ], +}; + +const StoryTitle = ({ children }) => { + const customStyles = { + margin: 0, + marginBottom: 10 + 'px', + color: '#333', + fontSize: 14 + 'px', + lineHeight: 22 + 'px', + }; + + return ( +

{ children }

+ ); +} + +const StoryDescription = ({ children }) => { + const customStyles = { + margin: 0, + marginBottom: 10 + 'px', + }; + + return ( +

+ { children } +

+ ); +} + +const StoryCode = ({ spaceTop = 5, spaceBottom = 20, children }) => { + const customStyles = { + display: 'block', + margin: 0, + marginTop: spaceTop + 'px', + marginBottom: spaceBottom + 'px', + padding: 5 + 'px ' + 10 + 'px', + }; + + return ( + { children } + ); +} + +const StorySection = ({ title, description, code, code2, isDefault = false, isLast = false, children }) => { + return ( + <> + { title && '' !== title && ( + { title }{ isDefault && ( + + )} + )} + { description && '' !== description && ( + { description } + )} + { code && '' !== code && ( + { code } + )} + { code2 && '' !== code2 && ( + { code2 } + )} + { children } + { !isLast &&
} + + ); +} + +const simpleContent = [ + { + id: "unique-id-1", + label: "Checked", + labelId: "label-id-1", + icon: "info", + checked: true, + }, + { + id: "unique-id-2", + label: "Unchecked", + labelId: "label-id-2", + icon: "info", + }, + { + id: "unique-id-3", + label: "Unchecked", + labelId: "label-id-3", + icon: "info", + }, + { + id: "unique-id-4", + label: "Unchecked", + labelId: "label-id-4", + icon: "info", + }, + { + id: "unique-id-5", + label: "Unchecked", + labelId: "label-id-5", + icon: "info", + disabled: true, + isPro: true, + }, +]; + +const simpleVerticalContent = [ + { + id: "vertical-unique-id-1", + label: "Checked", + labelId: "vertical-label-id-1", + checked: true, + icon: "info", + vertical: true, + }, + { + id: "vertical-unique-id-2", + label: "Unchecked", + labelId: "vertical-label-id-2", + icon: "info", + vertical: true, + }, + { + id: "vertical-unique-id-3", + label: "Unchecked", + labelId: "vertical-label-id-3", + icon: "info", + vertical: true, + }, + { + id: "vertical-unique-id-4", + label: "Unchecked", + labelId: "vertical-label-id-4", + icon: "info", + vertical: true, + }, + { + id: "vertical-unique-id-5", + label: "Unchecked", + labelId: "vertical-label-id-5", + icon: "info", + vertical: true, + disabled: true, + isPro: true, + }, +]; + +const compoundContent = [ + { + id: "compound-unique-id-1", + label: "Checked", + labelId: "compound-label-id-1", + icon: "info", + description: "This is a description", + descriptionId: "compound-description-id-1", + checked: true, + }, + { + id: "compound-unique-id-2", + label: "Unchecked", + labelId: "compound-label-id-2", + icon: "info", + description: "This is a description", + descriptionId: "compound-description-id-2", + }, + { + id: "compound-unique-id-3", + label: "Unchecked", + labelId: "compound-label-id-3", + icon: "info", + description: "This is a description", + descriptionId: "compound-description-id-3", + }, + { + id: "compound-unique-id-4", + label: "Unchecked", + labelId: "compound-label-id-4", + icon: "info", + description: "This is a description", + descriptionId: "compound-description-id-4", + }, + { + id: "compound-unique-id-5", + label: "Unchecked", + labelId: "compound-label-id-5", + icon: "info", + description: "This is a description", + descriptionId: "compound-description-id-5", + disabled: true, + isPro: true, + }, +]; + +const compoundVerticalContent = [ + { + id: "vertical-compound-unique-id-1", + label: "Checked", + labelId: "vertical-compound-label-id-1", + icon: "info", + description: "This is a description", + descriptionId: "vertical-compound-description-id-1", + checked: true, + vertical: true, + }, + { + id: "vertical-compound-unique-id-2", + label: "Unchecked", + labelId: "vertical-compound-label-id-2", + icon: "info", + description: "This is a description", + descriptionId: "vertical-compound-description-id-2", + vertical: true, + }, + { + id: "vertical-compound-unique-id-3", + label: "Unchecked", + labelId: "vertical-compound-label-id-3", + icon: "info", + description: "This is a description", + descriptionId: "vertical-compound-description-id-3", + vertical: true, + }, + { + id: "vertical-compound-unique-id-4", + label: "Unchecked", + labelId: "vertical-compound-label-id-4", + icon: "info", + description: "This is a description", + descriptionId: "vertical-compound-description-id-4", + vertical: true, + }, + { + id: "vertical-compound-unique-id-5", + label: "Unchecked", + labelId: "vertical-compound-label-id-5", + icon: "info", + description: "This is a description", + descriptionId: "vertical-compound-description-id-5", + disabled: true, + isPro: true, + vertical: true, + }, +]; + +export const Default = () => { + return ( + <> + + + + + + + + ); +}; +Default.storyName = 'Default'; + +export const Vertical = () => { + return ( + <> + + + + + + + + ); +}; +Vertical.storyName = 'Vertical'; \ No newline at end of file diff --git a/packages/react-selectors/lib/react-selectors.js b/packages/react-selectors/lib/react-selectors.js new file mode 100644 index 00000000..1a5d25df --- /dev/null +++ b/packages/react-selectors/lib/react-selectors.js @@ -0,0 +1,61 @@ +import React from 'react' + +const Selectors = ({ + name, + columns = '', + content = [], +}) => { + let classes = 'sui-box-selectors'; + + switch (columns) { + case 'one': + classes += ' sui-box-selectors-col-1'; + break; + case 'two': + classes += ' sui-box-selectors-col-2'; + break; + case 'three': + classes += ' sui-box-selectors-col-3'; + break; + case 'four': + classes += ' sui-box-selectors-col-4'; + break; + case 'five': + classes += ' sui-box-selectors-col-5'; + break; + default: + break; + } + + return ( +
+ +
+ ) +} + +export { Selectors } diff --git a/packages/react-selectors/package.json b/packages/react-selectors/package.json new file mode 100644 index 00000000..6b5cc4d6 --- /dev/null +++ b/packages/react-selectors/package.json @@ -0,0 +1,30 @@ +{ + "name": "@wpmudev/react-selectors", + "version": "1.0.0", + "description": "Now I’m the model of a modern major general / The venerated Virginian veteran whose men are all / Lining up, to put me up on a pedestal / Writin’ letters to relatives / Embellishin’ my elegance and eloquence / But the elephant is in the room / The truth is in ya face when ya hear the British cannons go / BOOM", + "keywords": [], + "author": "Pawan Kumar ", + "license": "ISC", + "main": "lib/react-selectors.js", + "directories": { + "lib": "lib", + "test": "__tests__" + }, + "files": [ + "lib" + ], + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/wpmudev/shared-ui-react.git" + }, + "scripts": { + "test": "echo \"Error: run tests from root\" && exit 1" + }, + "bugs": { + "url": "https://github.com/wpmudev/shared-ui-react/issues" + }, + "homepage": "https://github.com/wpmudev/shared-ui-react#readme" +}