From 061a9396eb29a9fd8c1a46081af058d32249facb Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Wed, 3 Feb 2021 11:02:57 -0500 Subject: [PATCH 1/3] Updates button examples --- .../src/components/Button/Button.stories.tsx | 145 +++++++++++++++--- 1 file changed, 120 insertions(+), 25 deletions(-) diff --git a/packages/core/src/components/Button/Button.stories.tsx b/packages/core/src/components/Button/Button.stories.tsx index a5005574fe..98b6d46b25 100644 --- a/packages/core/src/components/Button/Button.stories.tsx +++ b/packages/core/src/components/Button/Button.stories.tsx @@ -17,6 +17,17 @@ import React, { FunctionComponentFactory } from 'react'; import { Button } from './Button'; import { MemoryRouter, Route, useLocation } from 'react-router-dom'; import { createRouteRef } from '@backstage/core-api'; +import { + Divider, + Grid, + Link, + List, + ListItem, + ListItemText, + ListSubheader, + Typography, + Button as MaterialButton, +} from '@material-ui/core'; const Location = () => { const location = useLocation(); @@ -28,14 +39,27 @@ export default { component: Button, decorators: [ (storyFn: FunctionComponentFactory<{}>) => ( - -
+ <> + + A collection of buttons that should be used in the Backstage + interface. These leverage the properties inherited from{' '} + + Material-UI Button + + , but include an opinionated set that align to the Backstage design. + + + + +
- +
+ +
+ {storyFn()}
- {storyFn()} -
-
+ + ), ], }; @@ -46,36 +70,107 @@ export const Default = () => { title: 'Hi there!', }); + // Design Permutations: + // color = default | primary | secondary + // variant = contained | outlined | text return ( - <> -  will utilise the - react-router MemoryRouter's navigation - -

{routeRef.title}

-
- + + + + Default Button: + This is the default button design which should be used in most cases. +
+
color="primary" variant="contained"
+
+ + +
+ + + Secondary Button: + Used for actions that cancel, skip, and in general perform negative + functions, etc. +
+
color="secondary" variant="contained"
+
+ + +
+ + + Tertiary Button: + Used commonly in a ButtonGroup and when the button function itself is + not a primary function on a page. +
+
color="default" variant="outlined"
+
+ + +
+
); }; -export const PassProps = () => { +export const ButtonLinks = () => { const routeRef = createRouteRef({ path: '/hello', title: 'Hi there!', }); + const handleClick = () => { + return 'Your click worked!'; + }; + return ( <> - -  has props for both material-ui's component as well as for - react-router-dom's - -

{routeRef.title}

-
+ + { + // TODO: Refactor to use new routing mechanisms + } + + +   has props for both Material-UI's component as well as for + react-router-dom's Route object. + + + + +   links to a statically defined route. In general, this should be + avoided. + + + + + View URL + +   links to a defined URL using Material-UI's Button. + + + + + Trigger Event + +   triggers an onClick event using Material-UI's Button. + + ); }; -PassProps.story = { - name: `Accepts material-ui Button's and react-router-dom Link's props`, -}; From f2e106df0a8238814b3f316fa8a3fc561bde5f9a Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Wed, 3 Feb 2021 12:33:22 -0500 Subject: [PATCH 2/3] Fix TypeScript compile errors --- packages/core/src/components/Button/Button.stories.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/core/src/components/Button/Button.stories.tsx b/packages/core/src/components/Button/Button.stories.tsx index 98b6d46b25..a0756925d6 100644 --- a/packages/core/src/components/Button/Button.stories.tsx +++ b/packages/core/src/components/Button/Button.stories.tsx @@ -15,16 +15,14 @@ */ import React, { FunctionComponentFactory } from 'react'; import { Button } from './Button'; -import { MemoryRouter, Route, useLocation } from 'react-router-dom'; +import { MemoryRouter, useLocation } from 'react-router-dom'; import { createRouteRef } from '@backstage/core-api'; import { Divider, - Grid, Link, List, ListItem, ListItemText, - ListSubheader, Typography, Button as MaterialButton, } from '@material-ui/core'; From ff9c940ca7fd944208e97ed376763e7a39092003 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Wed, 3 Feb 2021 12:34:51 -0500 Subject: [PATCH 3/3] Fix props --- packages/core/src/components/Button/Button.stories.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/components/Button/Button.stories.tsx b/packages/core/src/components/Button/Button.stories.tsx index a0756925d6..af95e64d52 100644 --- a/packages/core/src/components/Button/Button.stories.tsx +++ b/packages/core/src/components/Button/Button.stories.tsx @@ -132,7 +132,7 @@ export const ButtonLinks = () => { // TODO: Refactor to use new routing mechanisms } -   has props for both Material-UI's component as well as for @@ -140,7 +140,7 @@ export const ButtonLinks = () => { -   links to a statically defined route. In general, this should be @@ -150,7 +150,7 @@ export const ButtonLinks = () => { View URL @@ -161,7 +161,7 @@ export const ButtonLinks = () => { Trigger Event