playbook_ui 2.8.8 → 2.8.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -289
  3. data/app/pb_kits/playbook/packs/index.js +6 -0
  4. data/app/pb_kits/playbook/pb_body/_body.jsx +4 -4
  5. data/app/pb_kits/playbook/pb_button/_button_mixins.scss +1 -1
  6. data/app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx +75 -17
  7. data/app/pb_kits/playbook/pb_dashboard_value/docs/_dashboard_value_align.jsx +31 -0
  8. data/app/pb_kits/playbook/pb_dashboard_value/docs/_dashboard_value_default.jsx +20 -1
  9. data/app/pb_kits/playbook/pb_dashboard_value/docs/example.yml +2 -1
  10. data/app/pb_kits/playbook/pb_dashboard_value/docs/index.js +1 -0
  11. data/app/pb_kits/playbook/pb_date/date.rb +16 -2
  12. data/app/pb_kits/playbook/pb_date/docs/_date_default.html.erb +7 -0
  13. data/app/pb_kits/playbook/pb_icon/_icon.jsx +87 -18
  14. data/app/pb_kits/playbook/pb_icon/docs/_icon_animate.jsx +14 -0
  15. data/app/pb_kits/playbook/pb_icon/docs/_icon_border.jsx +12 -0
  16. data/app/pb_kits/playbook/pb_icon/docs/_icon_default.jsx +1 -1
  17. data/app/pb_kits/playbook/pb_icon/docs/_icon_default_dark.jsx +12 -0
  18. data/app/pb_kits/playbook/pb_icon/docs/_icon_flip.jsx +14 -0
  19. data/app/pb_kits/playbook/pb_icon/docs/_icon_pull.jsx +13 -0
  20. data/app/pb_kits/playbook/pb_icon/docs/_icon_rotate.jsx +14 -0
  21. data/app/pb_kits/playbook/pb_icon/docs/_icon_sizes.jsx +27 -0
  22. data/app/pb_kits/playbook/pb_icon/docs/example.yml +8 -1
  23. data/app/pb_kits/playbook/pb_icon/docs/index.js +7 -0
  24. data/app/pb_kits/playbook/pb_pill/_pill.jsx +19 -12
  25. data/app/pb_kits/playbook/pb_pill/_pill.scss +1 -1
  26. data/app/pb_kits/playbook/pb_pill/pill.rb +1 -3
  27. data/app/pb_kits/playbook/pb_stat_change/_stat_change.jsx +78 -18
  28. data/app/pb_kits/playbook/pb_stat_change/docs/_stat_change_default.jsx +11 -1
  29. data/app/pb_kits/playbook/pb_stat_value/_stat_value.jsx +44 -16
  30. data/app/pb_kits/playbook/pb_stat_value/docs/_stat_value_default.jsx +1 -1
  31. data/app/pb_kits/playbook/pb_stat_value/docs/_stat_value_unit.jsx +10 -0
  32. data/app/pb_kits/playbook/pb_stat_value/docs/example.yml +1 -0
  33. data/app/pb_kits/playbook/pb_stat_value/docs/index.js +1 -0
  34. data/app/pb_kits/playbook/pb_toggle/_toggle.html.erb +1 -1
  35. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_custom.html.erb +3 -0
  36. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_custom_radio.html.erb +22 -0
  37. data/app/pb_kits/playbook/pb_toggle/docs/_toggle_name.html.erb +14 -18
  38. data/app/pb_kits/playbook/pb_toggle/docs/example.yml +2 -0
  39. data/app/pb_kits/playbook/pb_toggle/toggle.rb +19 -5
  40. data/lib/playbook/version.rb +1 -1
  41. metadata +13 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61c58765172511056b14d6c3ecf08d6770d79ec343011f55da235ef43d337737
4
- data.tar.gz: f7789d51bc27282142e0ad087f0b06337988409370aeaf1ab3be7c89a8e4b665
3
+ metadata.gz: 4f9e84db4ccb31383e19cb882e7225455d347fda5571daed019d79d8b8daf716
4
+ data.tar.gz: 6b34648478a78f753458727976e3dce218f34fcd24aba24eeee38ec312dd2c55
5
5
  SHA512:
6
- metadata.gz: '068062e848cb483ce0e9c174a37eb4f3ba203ed06e113a7d79338267aa69b51d6f02580e6a443c76a757ca03f0053dd5f250a095a0b0f94a7fe23b11e808aef4'
7
- data.tar.gz: 522f98246b9a15eced512ab65ceb75b155c9796514fc9822882b28f823674a210725749c998bf56c271fe4d24ccaafa3c0a69b07be5a34be5038bc23cb336d84
6
+ metadata.gz: 3568843cb54b4e11011ce9bd16c07880acb30b8404d0d59b57f137c03f9abee485e6970aef9683a7ed955e8ec09b78dd4f1bf2c38760c21368bb8002056cc10b
7
+ data.tar.gz: 651148155a79e850637f7217f714f7e38d3aa5d7164be550ec00a70f210a0ff4efe05b5b7da475482db77a533d5e2e7c44bbd8e0b693f253c4b2696f421b5b5d
data/README.md CHANGED
@@ -1,9 +1,6 @@
1
- # UI Playbook
1
+ # Playbook Design System
2
2
 
3
- UIX Styleguide & Documentation
4
-
5
- #### Demo
6
- [View Demo](http://afternoon-refuge-87160.herokuapp.com/)
3
+ Playbook is the first design system built for both Rails & React interfaces. Inspired by [Velocity](https://www.invisionapp.com/inside-design/design-resources/design-system-dashboard-ui-kit/), Playbook takes a modern design approach, and applies it in a way that makes it easy to support bleeding edge, or legacy systems. Playbook is built & maintained by the User Experience & Developemnt teams at Power Home Remodeling, the largest home remodeler in the US.
7
4
 
8
5
  ## Requirements
9
6
 
@@ -12,11 +9,16 @@ UIX Styleguide & Documentation
12
9
 
13
10
  ## Getting started
14
11
 
12
+ 1. Run `yarn && bundle`
15
13
  1. Run `make start`
16
14
  1. Bootstrap the database: `docker-compose run web bin/rails db:setup`
17
15
  1. open [http://localhost:8080](http://localhost:8080)
18
16
 
19
- When making changes to the Gemfile:
17
+ To clean up this project from your local machine, run `make stop`, which will drop all containers and networks associated with this project. To purge all resources, do `make clean`, which also removes images and volumes for a blank slate.
18
+
19
+
20
+ <details><summary>Making changes to the Gemfile:</summary>
21
+ <p>
20
22
 
21
23
  * Stop the `make start` process
22
24
  * Run `make bundle` to (un-)install gems and update the `Gemfile.lock`
@@ -24,293 +26,25 @@ When making changes to the Gemfile:
24
26
 
25
27
  To run the tests, do `make test`. To launch a shell in the container run `make shell`, or to launch a Rails console run `make console`
26
28
 
27
- To clean up this project from your local machine, run `make stop`, which will drop all containers and networks associated with this project. To purge all resources, do `make clean`, which also removes images and volumes for a blank slate.
28
-
29
- ### Configuration
30
-
31
- The application is configured through a set of environment variables which can be tweaked in the `.env` file for local development; these should not be committed unless they are generally applicable.
32
-
33
- ## Deployments
34
-
35
- * A staging environment is automatically deployed on every master build. Manual deployments are possible (via `make deploy cluster=APP-HQ environment=staging tag=PR-X-$SHA1-$BUILDNUMBER`) but are discouraged.
36
- * A production environment that is automatically deployed on every master build. Manual deployments are strongly discouraged.
37
-
38
- These environments are deployed from the same container used for local development, which is built by CI on every commit.
39
-
40
- In order to work with these, you'll need to have [setup APP access](https://github.com/powerhome/APP#getting-access).
41
-
42
- ### Configuring the application deployed to APP
43
-
44
- The Helm chart stored in `charts/playbook` defines the resource types deployed to the application platform as templates which are customised with specific values for each environment. The standard values are held in `charts/playbook/values.yaml`, while per-environment overrides (including secrets) are stored in `config/deploy/[environment]/[values|secrets].yaml`. Standard values are in plain text, while secrets (API keys etc) are encrypted (more below). These templates and values may be modified to affect the deployment, but attention must be given to any template or defaults changes to ensure they apply correctly to all environments, and also to minimizing the differences between environments where possible.
45
-
46
- The most common changes expected to be required are to the set of environment variables passed to the app at runtime. These values are passed to the app via the `spec -> template -> spec -> containers -> env` entry in the deployment template, where the values are extracted from those provided to the template or from a Kubernetes Secret. In the plain-text case, the values simply need to be defined in a values.yaml to be interpolated. In the case of secrets, they must be first passed into the secret template. Examples of both exist and should be followed.
47
-
48
- #### Dealing with encrypted secrets
49
-
50
- Encrypted secrets are perhaps the most complex part of the deployment setup. These secrets must be known to the app at runtime, for example to connect to the Nitro API, and must be included in the application repository in order to simplify coordination of configuration changes, but must not be stored at rest in plain text. They are thus encrypted in `secrets.yaml` files in the git repository, in such a way that developers can decrypt them (to make changes) and Jenkins can decrypt them (to pass to Helm for deployment). The encryption is done using GPG keys using [`helm-secrets`](https://github.com/futuresimple/helm-secrets) and [`sops`](https://github.com/mozilla/sops).
51
-
52
- To begin managing secrets, one must install these dependencies (for local use) or use the `make secrets` container to manage them. An example of usage of the container:
53
-
54
- ```
55
- [Thu Feb 22 08:59:09]$ make secrets
56
- docker run --tty --interactive --rm --volume ~/.kube:/root/.kube --volume ~/.gnupg/secring.gpg:/root/.gnupg/secring.gpg --volume ~/.gnupg/pubring.gpg:/root/.gnupg/pubring.gpg --volume ~/.gnupg/private-keys-v1.d:/root/.gnupg/private-keys-v1.d --volume /Users/garettarrowood/Power/playbook:/app --entrypoint /bin/gpg-agent-background docker-registry.powerhrg.com/platform/deployer:master-6cf477240dd6b4f180f0f8da980805ddf6fc4fe0-18 bash --login
57
- root@4ead1d121f65:/app# helm secrets view config/deploy/staging/secrets.yaml
58
- ```
59
-
60
- #### Common tasks:
61
-
62
- ##### Requesting access to secrets
63
-
64
- 1. Find your GPG key fingerprint using `gpg --list-secret-keys`. Generate a key if you don't already have one (see https://help.github.com/articles/generating-a-new-gpg-key/).
65
- 1. Add your key to the keyring: `make addKeyToRing fingerprint=[FINGERPRINT]`
66
- 1. Include your key fingerprint in `.sops.yaml`.
67
- 1. Submit a PR including these changes.
68
- 1. Ask someone who already has access to follow the grant routine below.
69
-
70
- ##### Granting access to secrets
71
-
72
- 1. Checkout the access request PR.
73
- 1. Run `make grantSecretAccess fingerprint=[THE REQUESTED FINGERPRINT]`.
74
- 1. Commit the changes to `secrets.yaml` files that result and push to the PR.
75
- 1. Ask the requester to confirm they can read the secrets, then merge the PR.
76
-
77
- ##### Reading secrets
78
-
79
- Run `helm secrets view config/deploy/[ENVIRONMENT]/secrets.yaml`.
80
-
81
- ##### Editing secrets
82
-
83
- 1. Run `helm secrets edit config/deploy/[ENVIRONMENT]/secrets.yaml`.
84
- 1. Make your changes and save the file.
85
- 1. Commit the modified secrets file.
86
-
87
-
88
-
89
- ---
90
-
91
- # Old Storybook
92
-
93
- This repo provides the tools to implement view components which make up the visual appearance of Nitro.
94
-
95
- * Stylesheets for the app navigation and general appearance
96
- * Self-contained React components for use in building views
97
-
98
- The intent of this repo is to provide a base on which other UIs can be built such that they maintain visual consistency and the Nitro brand.
99
-
100
-
101
- - [Quick Start](#quick-start)
102
- - [Local Storybook Development in Nitro-Web](#local-storybook-development-in-nitro-web)
103
- - [Other options for storybook in Nitro-Web](#other-options-for-storybook-in-nitro-web)
104
- - [Getting Your Changes Into Nitro-Web](#getting-your-changes-into-nitro-web)
105
- - [Creating Components](#creating-components)
106
- - [Converting Existing Components](#converting-existing-components)
107
-
108
-
109
- ## Quick Start
110
- From the current project directory, run:
111
-
112
- 1. ensure you are running proper node version (see `package.json` => `engines`)
113
- 2. `yarn install`
114
- 3. `yarn run storybook`
115
- 4. navigate to [localhost:9001](http://localhost:9001)
116
-
117
- ---
118
-
119
- ## Local Storybook Development in Nitro-Web
120
- Its easy to create and test out a component on nitro in real time, even with hot reload. You can point your local storybook folder as you develop it.
121
-
122
- ##### Update the storybook in the Gemfile to a local path
123
- `gem "playbook", :path => "/path/to/storybook/locally"`
124
-
125
- ##### Update the storybook in package.json to a local path
126
- `”nitro-storybook": "/path/to/storybook/locally"`
127
-
128
- > if you have any problems with assets not showing try running:
129
- `bundle exec rake assets:clobber`
130
-
131
-
132
- ---
133
-
134
- ## Other options for storybook in Nitro-Web
135
- You’ll need to point to a something published on GitHub when your ready to deploy it. Here are some options for you:
136
-
137
- ##### Gemfile - Tag
138
- `gem "playbook", git: "git@github.com:powerhome/nitro-styleguide.git", tag: "v1.2.1"`
139
-
140
- ##### Gemfile - SHA
141
- `gem "playbook", git: "git@github.com:powerhome/nitro-styleguide.git", ref: "4aded"`
142
-
143
- ##### Gemfile - Branch
144
- `gem "playbook", git: "git@github.com:powerhome/nitro-styleguide.git", branch: "branchname"`
145
-
146
- ##### package.json - Branch
147
- `"nitro-storybook": "git+ssh://git@github.com/powerhome/nitro-storybook.git#branchname",`
148
-
149
-
150
- ---
151
-
152
- ## Getting Your Changes Into Nitro-Web
153
-
154
- ### 1. Increase your version
155
-
156
- Check the [releases](https://github.com/powerhome/nitro-storybook/releases) and increase your version by 1 in the following files:
157
-
158
- ```
159
- lib/playbook/version.rb
160
- package.json
161
- ```
162
-
163
- Be sure and run the following anytime you version up:
164
-
165
- `yarn install && bundle install`
166
-
167
-
168
- ### 2. Prep a Storybook PR
169
-
170
- Get your `nitro-storybook` PR approved and merged into the `nitro-storybook`'s `master` branch.
171
-
172
- ### 3. Create a Tag & Release
173
-
174
- Once your merged you need to create a tag so we can reference this version. Here are some easy ways to create and delete tags:
175
-
176
- ##### Add A Tag
177
- ```
178
- git tag v1.0.1
179
- git push origin v1.0.1
180
- ```
181
-
182
- ##### Remove A Tag
183
- ```
184
- git tag -d v1.0.1
185
- git push --delete origin v1.0.1
186
- ```
187
-
188
- ### 4. Update references in Nitro Web
189
-
190
- ##### Package.json
191
- `"nitro-storybook": "git+ssh://git@github.com/powerhome/nitro-storybook.git#v1.9.2",`
192
-
193
- ##### Gemfile (Usually 4 Spots)
194
- ```
195
- gem "playbook", git: "git@github.com:powerhome/nitro-storybook.git", tag: "v1.9.2"
196
- ```
197
-
198
- If your updated styling doesn’t show up, you may have old assets you need to remove.
199
- `bundle exec rake assets:clobber`
200
-
201
- ---
202
-
203
- ## Creating Components
204
-
205
- Creation of new components requires a bit of forethought. Ask yourself these questions first:
206
-
207
- 1. Does the component already exist in `nitro_react` ?
208
- 1. Yes - see [Converting Existing Components](#converting-existing-components)
209
- 1. No - continue
210
- 1. Ensure you are familiar with these concepts:
211
- - using Flow.js (install tooling in your editor/IDE)
212
- - creating "dumb components" in React - your new component **will not** need to be concerned with XHR requests, servers, ect.
213
- - ESLint (install tooling in your editor/IDE)
214
- - CSSModules
215
- - Composing complex React components/organisms (so that you don't create them here!)
216
- - [Storybook]()
217
-
218
- ### New React Component
219
-
220
- Here are the steps to creating a new `Foo` component (in order):
221
-
222
- 1. Create a new directory under `/components` named `Foo`
223
- 1. Create `Foo.jsx` inside the directory with the contents:
224
- ```javascript
225
- /* @flow */
226
-
227
- import React from 'react'
228
-
229
- type Props = {}
230
-
231
- export default class Foo extends React.Component<Props> {
232
- static defaultProps = {}
233
- props: Props
234
- render() {
235
- return <span>{`I'm a Foo`}</span>
236
- }
237
- }
238
-
239
- ```
240
- 1. Create `styles.scss` inside the directory with the contents:
241
- ```scss
242
- .foo {}
243
- ```
244
- 1. Add the stylesheet as an import by adding this line:
245
- ```javascript
246
- import styles from './styles.scss'
247
- ```
248
- 1. Then make use of the import by adding `styles.foo` as the `className`:
249
- ```javascript
250
- render() {
251
- return <span className={styles.foo}>{`I'm a Foo`}</span>
252
- }
253
- ```
254
- 1. Add `Foo.jsx` to the component index in `components/index.js`
255
- ```javascript
256
- export Foo from './Foo/Foo.jsx'
257
- ```
258
-
259
- #### Create the Story
260
-
261
- 1. Within the same directory, create a `FooStory.jsx` with the contents:
262
- ```javascript
263
- import React from "react"
264
- import Foo from "./Foo"
29
+ </p>
30
+ </details>
265
31
 
266
- import { text, select, boolean } from "@storybook/addon-knobs"
32
+ ## Additional resources
267
33
 
268
- export default function FooStory(stories) {
269
- stories.add("Foo",
270
- () => {
271
- let props = {}
272
- return (
273
- <Foo {...props}/>
274
- )
275
- }
276
- )
277
- }
278
- ```
279
- 1. Add the story to the appropriate story index. This will depend on the intent of your component. `Foo` is pretty simply 😁, hence we will add it to `/stories/basic.js` like so:
280
- ```javascript
281
- export FooStory from '../components/Foo/FooStory'
282
- ```
283
- This will add your `Foo` story to the categoy "Basic Components" in Storybook
34
+ ### Nitro & Releases
284
35
 
285
- ---
36
+ * [Integrating Playbook Kits into Nitro Components](https://github.com/powerhome/playbook/wiki/Integrating-Playbook-Kits-into-Nitro-Components)
37
+ * [Creating Releases](https://github.com/powerhome/playbook/wiki/Releasing-a-New-Version)
286
38
 
287
- ## Converting Existing Components
39
+ ### Development Environment
288
40
 
289
- Conversion of existing components in `nitro_react` is a little different since we already have a decent class structure in the jsx component. There are, however, a few considerations:
41
+ * [Common Errors & Solutions](https://github.com/powerhome/playbook/wiki/Common-Errors-&-Solutions)
290
42
 
291
- - Use Flow.js types instead of `PropTypes`
292
- - use `class` instead of `function` (see the examples below)
293
- - Try and fix as many eslint and Flow warnings as possible - this is your chance and the time is now! 😬 💀
43
+ ### Building Playbook Kits
294
44
 
295
- 1. Create a `Props` flow type
296
- ```javascript
297
- type Props = {
298
- children?: Array<React.Node>,
299
- bold: boolean,
300
- italic: boolean,
301
- className: string,
302
- }
303
- ```
304
- 1. Add the type to your class
305
- ```javascript
306
- export default class Foo extends React.Component<Props> {
307
- static defaultProps = {}
308
- props: Props
309
- ...
310
- ```
311
- 1. You can still deconstruct `this.props` in any of your methods in the normal way
312
- ```javascript
313
- const {bar} = this.props
314
- ```
315
- 1. Lint your code `yarn run lint`
316
- 1. For some lint warning you can `yarn run lint-fix` which will automagically fix things like indentation.
45
+ * [Generating a Kit](https://github.com/powerhome/playbook/wiki/Generating-a-Kit)
46
+ * [Rails Kit](https://github.com/powerhome/playbook/wiki/Rails-Kit)
47
+ * [Rails Kit Helpers](https://github.com/powerhome/playbook/wiki/Rails-Kit-Helpers)
48
+ * [Using a Kit within a Kit](https://github.com/powerhome/playbook/wiki/Using-a-Kit-within-a-Kit)
49
+ * [Understanding Rails Kit HTML Wrapper](https://github.com/powerhome/playbook/wiki/Understanding-Rails-Kit-HTML-Wrapper)
50
+ * [Kit Stylesheet](https://github.com/powerhome/playbook/wiki/Kit-Stylesheet)
@@ -20,6 +20,9 @@ import TimeStamp from "../pb_timestamp/_timestamp";
20
20
  import Title from "../pb_title/_title";
21
21
  import User from "../pb_user/_user";
22
22
  import VerticalNav from "../pb_vertical_nav/_vertical_nav";
23
+ import Pill from "../pb_pill/_pill";
24
+ import Currency from "../pb_currency/_currency";
25
+ import Toggle from "../pb_toggle/_toggle";
23
26
 
24
27
  // Dashboard Settings
25
28
  import commonSettings from "../pb_dashboard/commonSettings";
@@ -53,6 +56,9 @@ export {
53
56
  Title,
54
57
  User,
55
58
  VerticalNav,
59
+ Pill,
60
+ Currency,
61
+ Toggle,
56
62
  commonSettings,
57
63
  lineGraphSettings,
58
64
  barGraphSettings,
@@ -14,14 +14,14 @@ type BodyProps = {
14
14
  }
15
15
 
16
16
  const bodyCSS = ({
17
- color='light',
17
+ color='default',
18
18
  dark=false,
19
19
  status='',
20
20
 
21
21
  }: BodyProps) => {
22
22
 
23
23
  const colorStyle = color !== '' ? `_${color}` : ''
24
-
24
+
25
25
  const themeStyle = dark === true ? '_dark' : ''
26
26
 
27
27
  const statusStyle = status !== '' ? `_${status}` : ''
@@ -33,12 +33,12 @@ const Body = (props: BodyProps) => {
33
33
  const {
34
34
  className,
35
35
  children,
36
- text,
36
+ text,
37
37
  tag='p',
38
38
  } = props
39
39
 
40
40
  const Tag = `${tag}`
41
-
41
+
42
42
  return (
43
43
  <Tag className={classnames(bodyCSS(props), className)}>
44
44
  { text || children }
@@ -15,7 +15,7 @@ $pb_button_border_width: 1px;
15
15
  @mixin pb_button($bg: $primary_action, $color: $text_dk_default, $border: transparent) {
16
16
  text-rendering: optimizeLegibility;
17
17
  font-size: $font_small;
18
- font-weight: $regular;
18
+ font-weight: $bold;
19
19
  text-align: center;
20
20
  vertical-align: middle;
21
21
  text-transform: none;
@@ -1,21 +1,79 @@
1
- import React from 'react';
2
- import PropTypes from "prop-types";
3
-
4
- const propTypes = {
5
- className: PropTypes.string,
6
- id: PropTypes.string
7
- };
8
-
9
- class DashboardValue extends React.Component {
10
- render() {
11
- return (
12
- <div className="pb_dashboard_value">
13
- <span>DASHBOARD VALUE CONTENT</span>
14
- </div>
15
- )
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import classnames from 'classnames'
5
+ import Body from '../pb_body/_body.jsx'
6
+ import StatChange from '../pb_stat_change/_stat_change.jsx'
7
+ import StatValue from '../pb_stat_value/_stat_value.jsx'
8
+
9
+ type DashboardValueProps = {
10
+ align?: 'left' | 'center' | 'right',
11
+ className?: String,
12
+ id?: String,
13
+ stat_change?: {
14
+ change?: String,
15
+ value?: String | Number
16
+ },
17
+ stat_label?: {
18
+ label?: String
19
+ },
20
+ stat_value?: {
21
+ unit?: String,
22
+ value?: String | Number
16
23
  }
17
24
  }
18
25
 
19
- DashboardValue.propTypes = propTypes;
26
+ const dashboardValueCSS = ({
27
+ align='left',
28
+
29
+ }: DashboardValueProps) => {
30
+
31
+ const alignStyle = align !== '' ? `_${align}` : ''
32
+
33
+ return 'pb_dashboard_value_kit' + alignStyle
34
+ }
35
+
36
+ const DashboardValue = (props: DashboardValueProps) => {
37
+ const {
38
+ align='left',
39
+ className,
40
+ id,
41
+ stat_change,
42
+ stat_label,
43
+ stat_value,
44
+ } = props
45
+
46
+ const statLabel = function(stat_label) {
47
+ if (stat_label) {
48
+ return (
49
+ <Body color="light">{stat_label.label}</Body>
50
+ )
51
+ }
52
+ }
53
+
54
+ const statChange = function(stat_change) {
55
+ if (stat_change) {
56
+ return (
57
+ <StatChange change={stat_change.change} value={stat_change.value} />
58
+ )
59
+ }
60
+ }
61
+
62
+ const statValue = function(stat_value) {
63
+ if (stat_value) {
64
+ return (
65
+ <StatValue value={stat_value.value} unit={stat_value.unit} />
66
+ )
67
+ }
68
+ }
69
+
70
+ return (
71
+ <div id={id} className={classnames(dashboardValueCSS(props), className)}>
72
+ {statLabel(stat_label)}
73
+ {statValue(stat_value)}
74
+ {statChange(stat_change)}
75
+ </div>
76
+ )
77
+ }
20
78
 
21
- export default DashboardValue;
79
+ export default DashboardValue