From a4c7f4ce5804cf67db671c332f7556cd2973c21a Mon Sep 17 00:00:00 2001 From: Maria Navarro Date: Tue, 8 Feb 2022 13:52:16 -0600 Subject: [PATCH] feat(docs): update button page to use new layout --- .../components/CodePreview/CodePreview.tsx | 4 - packages/docs/pages/button.tsx | 340 +++++++++++------- 2 files changed, 208 insertions(+), 136 deletions(-) diff --git a/packages/docs/components/CodePreview/CodePreview.tsx b/packages/docs/components/CodePreview/CodePreview.tsx index 748fea409..1b7f69ee6 100644 --- a/packages/docs/components/CodePreview/CodePreview.tsx +++ b/packages/docs/components/CodePreview/CodePreview.tsx @@ -89,7 +89,3 @@ export const CodePreview: React.FC = (props) => { ); }; - -CodePreview.defaultProps = { - scope: defaultScope, -}; diff --git a/packages/docs/pages/button.tsx b/packages/docs/pages/button.tsx index 1c6c1e229..ab69dd8c1 100644 --- a/packages/docs/pages/button.tsx +++ b/packages/docs/pages/button.tsx @@ -1,145 +1,221 @@ import { Button, H1, Panel, Text } from '@bigcommerce/big-design'; import { AddIcon, ArrowDropDownIcon } from '@bigcommerce/big-design-icons'; -import React, { useEffect, useState } from 'react'; +import React, { Fragment, useEffect, useState } from 'react'; -import { Code, CodePreview, PageNavigation } from '../components'; +import { Code, CodePreview, ContentRoutingTabs, GuidelinesTable, List } from '../components'; import { ButtonPropTable, MarginPropTable } from '../PropTables'; const ButtonPage = () => { - const items = [ - { - id: 'examples', - title: 'Examples', - render: () => ( - <> - - Buttons are calls to action used throughout the product experience. - - {/* jsx-to-string:start */} - - {/* jsx-to-string:end */} - - - - - There are three types of variants to choose from: primary, secondary, and{' '} - subtle. You can determine what type of variant by using the variant{' '} - prop. - - - - {/* jsx-to-string:start */} - <> - - - - - {/* jsx-to-string:end */} - - - - - There are two action types: normal & destructive. They are used to indicate - the nature of the action when clicking on the button. - - - - {/* jsx-to-string:start */} - <> - - - - {/* jsx-to-string:end */} - - - - The loading state is used when clicking a button will perform a asyncronous action. - - - {/* jsx-to-string:start */} - {function LoadingButton() { - const [isLoading, setLoading] = useState(false); - - function simulateNetworkRequest() { - return new Promise((resolve) => setTimeout(resolve, 2000)); - } - - useEffect(() => { - if (isLoading) { - simulateNetworkRequest().then(() => { - setLoading(false); - }); - } - }, [isLoading]); - - const handleClick = () => setLoading(true); - - return ( - - ); - }} - {/* jsx-to-string:end */} - - - - - A disabled state is used to indicate no action can be done using the button by passing a{' '} - disabled prop. - - - - {/* jsx-to-string:start */} - <> - - - - - {/* jsx-to-string:end */} - - - - - A button can also include icons on either side of the text (or both). When using{' '} - iconOnly, the iconLeft & iconRight{' '} - components will be removed. - - - - {/* jsx-to-string:start */} - <> - - - - - {/* jsx-to-string:end */} - - - - ), - }, - { - id: 'props', - title: 'Props', - render: () => } />, - }, - ]; - return ( <>

Button

- + + + Buttons trigger an immediate action, which can continue within the current page, a new + page or modal. + + When to use: + + + Use Primary Buttons for the most important action on a page (e.g. creating an object, + saving changes). + + + Use Secondary Buttons for other important page actions that are not the primary task on + the page. + + + Use Subtle Buttons alongside Secondary or{' '} + Primary Buttons for teritiary actions, like to cancel or visit a related task. + + + Use Destructive Buttons in confirmations for important actions that cannot be undone + (like deleting something). + + + + + + ( + <> + Buttons are calls to action used throughout the product experience. + + {/* jsx-to-string:start */} + + {/* jsx-to-string:end */} + + + ), + }, + { + id: 'variants', + title: 'Variants', + render: () => ( + + + There are three types of variants to choose from: primary, secondary, and{' '} + subtle. You can determine what type of variant by using the{' '} + variant prop. + + + + {/* jsx-to-string:start */} + <> + + + + + {/* jsx-to-string:end */} + + + ), + }, + { + id: 'action-types', + title: 'Action Types', + render: () => ( + + + There are two action types: normal & destructive. They are used to + indicate the nature of the action when clicking on the button. + + + + {/* jsx-to-string:start */} + <> + + + + {/* jsx-to-string:end */} + + + ), + }, + { + id: 'loading', + title: 'Loading', + render: () => ( + + The loading state is used when clicking a button will perform a asyncronous action. + + + {/* jsx-to-string:start */} + {function LoadingButton() { + const [isLoading, setLoading] = useState(false); + + function simulateNetworkRequest() { + return new Promise((resolve) => setTimeout(resolve, 2000)); + } + + useEffect(() => { + if (isLoading) { + simulateNetworkRequest().then(() => { + setLoading(false); + }); + } + }, [isLoading]); + + const handleClick = () => setLoading(true); + + return ( + + ); + }} + {/* jsx-to-string:end */} + + + ), + }, + { + id: 'disabled', + title: 'Disabled', + render: () => ( + + + A disabled state is used to indicate no action can be done using the button by passing a{' '} + disabled prop. + + + + {/* jsx-to-string:start */} + <> + + + + + {/* jsx-to-string:end */} + + + ), + }, + { + id: 'icons', + title: 'Icons', + render: () => ( + + + A button can also include icons on either side of the text (or both). When using{' '} + iconOnly, the iconLeft &{' '} + iconRight components will be removed. + + + + {/* jsx-to-string:start */} + <> + + + + + {/* jsx-to-string:end */} + + + ), + }, + ]} + /> + + + + } renderPanel={false} /> + + + + Keep button labels short and concise., + <> + Where there are multiple Buttons together, ensure the “default” action is the{' '} + Primary Button. + , + <> + Primary Buttons should only appear once per page. + , + ]} + discouraged={[ + <> + Have more than one Primary Button on a page. + , + ]} + /> + ); };