Skip to content

Commit

Permalink
Update README and convert Alert, Button to CSF (gravitational#5)
Browse files Browse the repository at this point in the history
* Convert Alert, Button to CSF
* Prettify and replace div wrappers w/ fragments
* Update README to include prettify setup

Part of: gravitational/webapps#3
  • Loading branch information
Lisa Kim authored Jan 22, 2020
1 parent bf0a6dd commit 8d6573b
Show file tree
Hide file tree
Showing 11 changed files with 251 additions and 120 deletions.
28 changes: 26 additions & 2 deletions web/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Gravitational Web Applications and Packages

This mono-repository contains the source code for the
Expand All @@ -12,7 +11,25 @@ the [packages directory](https://github.com/gravitational/webapps/tree/master/pa

You can make production builds locally or you can use Docker to do that.

### Setup Prettier on VSCode

1. Install plugin: https://github.com/prettier/prettier-vscode
1. Go to Command Palette: CMD/CTRL + SHIFT + P
1. Type `open settings`
1. Select `Open Settings (JSON)`
1. Include the below snippet and save:

```
// Set the default
"editor.formatOnSave": false,
// Enable per-language
"[javascript]": {
"editor.formatOnSave": true
}
```

### Local Build

Make sure that [you have yarn installed](https://yarnpkg.com/lang/en/docs/install/#debian-stable)
on your system since this monorepo uses the yarn package manager.

Expand All @@ -39,16 +56,19 @@ The resulting output will be in `/packages/teleport/dist/` and `/packages/gravit
### Docker Build

To build Teleport Web UI

```
$ make teleport
```

To build Gravity Web UI

```
$ make gravity
```

## Development

To avoid having to install a dedicated Teleport or Gravity cluster,
you can use a local development server which can proxy network requests
to an existing cluster.
Expand All @@ -62,6 +82,7 @@ $ yarn start-teleport --target=https://example.com:3080/web
```

or to start your local Gravity development server

```
$ yarn start-gravity --target=https://example.com:3080/web
```
Expand All @@ -70,18 +91,20 @@ This service will serve your local javascript files and proxy network
requests to the given target.

> Keep in mind that you have to use a local user because social
logins (google/github) are not supported by development server.
> logins (google/github) are not supported by development server.
### Unit-Tests

We use [jest](https://jestjs.io/) as our testing framework.

To run all jest unit-tests:

```
$ yarn run test
```

To run jest in watch-mode

```
$ yarn run tdd
```
Expand All @@ -93,6 +116,7 @@ It allows us to browse our component library, view the different states of
each component, and interactively develop and test components.

To start a storybook:

```
$ yarn run storybook
```
Expand Down
35 changes: 35 additions & 0 deletions web/packages/design/src/Alert/Alert.story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright 2019 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import Alert from './index';

export default {
title: 'Design/Alert',
component: Alert,
};

export const Default = () => <Alert>Default is danger</Alert>;

export const Danger = () => <Alert kind="danger">Some error message</Alert>;

export const Warning = () => <Alert kind="warning">Some warning message</Alert>;

export const Informational = () => (
<Alert kind="info">Some informational message</Alert>
);

export const Success = () => <Alert kind="success">Some success message</Alert>;
38 changes: 0 additions & 38 deletions web/packages/design/src/Alert/alert.story.js

This file was deleted.

66 changes: 66 additions & 0 deletions web/packages/design/src/Button/Button.story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright 2019 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import Button, {
ButtonPrimary,
ButtonSecondary,
ButtonWarning,
} from './Button';

export default {
title: 'Design/Button',
};

export const Basics = () => (
<>
<div>
<ButtonPrimary mr={3}>Primary</ButtonPrimary>
<ButtonSecondary mr={3}>Secondary</ButtonSecondary>
<ButtonWarning>Warning</ButtonWarning>
</div>
<div>
<Button size="large" mr={3} mt={5}>
Large
</Button>
<Button size="medium" mr={3}>
Medium
</Button>
<Button size="small">Small</Button>
</div>
</>
);

export const Block = () => (
<>
<Button block mb={3}>
Primary Block Button
</Button>
<ButtonSecondary block mb={3}>
Secondary Block Button
</ButtonSecondary>
<ButtonWarning block>Warning Block Button</ButtonWarning>
</>
);

export const States = () => (
<>
<Button mr={3} disabled>
Disabled
</Button>
<Button autoFocus>Focused</Button>
</>
);
73 changes: 0 additions & 73 deletions web/packages/design/src/Button/button.story.js

This file was deleted.

8 changes: 6 additions & 2 deletions web/packages/design/src/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import Button, { ButtonPrimary, ButtonWarning, ButtonSecondary } from './Button';
import Button, {
ButtonPrimary,
ButtonWarning,
ButtonSecondary,
} from './Button';
export default Button;
export { ButtonPrimary, ButtonWarning, ButtonSecondary }
export { ButtonPrimary, ButtonWarning, ButtonSecondary };
62 changes: 62 additions & 0 deletions web/packages/design/src/ButtonIcon/ButtonIcon.story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2019 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import ButtonIcon from './ButtonIcon';
import { AddUsers, Trash, Ellipsis } from './../Icon';
import Flex from './../Flex';

export default {
title: 'Design/Button',
};

export const Icons = () => (
<>
<Flex mb={3}>
<ButtonIcon size={2}>
<AddUsers />
</ButtonIcon>
<ButtonIcon size={2}>
<Ellipsis />
</ButtonIcon>
<ButtonIcon size={2}>
<Trash />
</ButtonIcon>
</Flex>
<Flex mb={4}>
<ButtonIcon size={1}>
<AddUsers />
</ButtonIcon>
<ButtonIcon size={1}>
<Ellipsis />
</ButtonIcon>
<ButtonIcon size={1}>
<Trash />
</ButtonIcon>
</Flex>
<Flex>
<ButtonIcon size={0}>
<AddUsers />
</ButtonIcon>
<ButtonIcon size={0}>
<Ellipsis />
</ButtonIcon>
<ButtonIcon size={0}>
<Trash />
</ButtonIcon>
</Flex>
</>
);
2 changes: 1 addition & 1 deletion web/packages/design/src/ButtonIcon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ limitations under the License.
*/

import ButtonIcon from './ButtonIcon';
export default ButtonIcon;
export default ButtonIcon;
Loading

0 comments on commit 8d6573b

Please sign in to comment.