nitro_sg 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/components/Avatar/Avatar.jsx +96 -0
  3. data/components/Avatar/styles.scss +54 -0
  4. data/components/Avatar/styles.scss.flow +14 -0
  5. data/components/Badge/Badge.jsx +40 -0
  6. data/components/Badge/badges.scss +167 -0
  7. data/components/Badge/labels.scss +121 -0
  8. data/components/Badge/styles.scss +4 -0
  9. data/components/Badge/styles.scss.flow +38 -0
  10. data/components/Banner/Banner.jsx +54 -0
  11. data/components/Banner/styles.scss +75 -0
  12. data/components/Banner/styles.scss.flow +19 -0
  13. data/components/Button/Button.jsx +75 -0
  14. data/components/Card/Card.jsx +44 -0
  15. data/components/CircleButton/CircleButton.jsx +51 -0
  16. data/components/CircleButton/CircleButtonStory.jsx +25 -0
  17. data/components/CircleButton/styles.scss +33 -0
  18. data/components/CircleButton/styles.scss.flow +6 -0
  19. data/components/CollapsibleCard/CollapsibleCard.jsx +108 -0
  20. data/components/Color/Color.jsx +55 -0
  21. data/components/Color/styles.scss +6 -0
  22. data/components/Color/styles.scss.flow +5 -0
  23. data/components/ColorPickerInput/ColorPickerInput.jsx +99 -0
  24. data/components/ColorPickerInput/colorPickerInput.scss +10 -0
  25. data/components/ColorPickerInput/colorPickerInput.scss.flow +6 -0
  26. data/components/DOBInput/index.jsx +35 -0
  27. data/components/DOBInput/story.jsx +20 -0
  28. data/components/DOBInput/styles.scss +11 -0
  29. data/components/DOBInput/styles.scss.flow +7 -0
  30. data/components/DatePicker/DatePicker.jsx +156 -0
  31. data/components/DatePicker/styles.scss +6 -0
  32. data/components/DatePicker/styles.scss.flow +5 -0
  33. data/components/DateTimePicker/DateTimePicker.jsx +109 -0
  34. data/components/DateTimePicker/story-styles.scss +3 -0
  35. data/components/DateTimePicker/story-styles.scss.flow +5 -0
  36. data/components/DateTimePicker/styles.scss +1 -0
  37. data/components/DateTimePicker/styles.scss.flow +5 -0
  38. data/components/Errors/Errors.jsx +38 -0
  39. data/components/FileCard/FileCard.jsx +183 -0
  40. data/components/FileCard/styles.scss +81 -0
  41. data/components/FileCard/styles.scss.flow +12 -0
  42. data/components/Flip/Flip.jsx +50 -0
  43. data/components/Flip/styles.scss +41 -0
  44. data/components/Flip/styles.scss.flow +11 -0
  45. data/components/FlyoutPanel/FlyoutPanel.jsx +34 -0
  46. data/components/FlyoutPanel/flyout_panel.scss +33 -0
  47. data/components/FlyoutPanel/flyout_panel.scss.flow +11 -0
  48. data/components/Grade/Grade.jsx +55 -0
  49. data/components/Grade/grade.scss +39 -0
  50. data/components/Grade/grade.scss.flow +6 -0
  51. data/components/Highlight/Highlight.jsx +39 -0
  52. data/components/Highlight/styles.scss +24 -0
  53. data/components/Highlight/styles.scss.flow +17 -0
  54. data/components/Icon/Icon.jsx +54 -0
  55. data/components/IconToggle/IconToggle.jsx +56 -0
  56. data/components/Milestones/MilestoneItem.jsx +47 -0
  57. data/components/Milestones/Milestones.jsx +51 -0
  58. data/components/Milestones/milestones.scss +19 -0
  59. data/components/Milestones/milestones.scss.flow +7 -0
  60. data/components/Milestones/milestones_item.scss +157 -0
  61. data/components/Milestones/milestones_item.scss.flow +13 -0
  62. data/components/Milestones/milestones_variables.scss +11 -0
  63. data/components/MonogramAvatar/MonogramAvatar.jsx +91 -0
  64. data/components/MonogramAvatar/monogram_avatar.scss +54 -0
  65. data/components/MonogramAvatar/monogram_avatar.scss.flow +10 -0
  66. data/components/Panel/Panel.jsx +159 -0
  67. data/components/Panel/panel.scss +32 -0
  68. data/components/Panel/panel.scss.flow +12 -0
  69. data/components/PanelGroup/PanelGroup.jsx +121 -0
  70. data/components/PanelGroup/PanelGroup.scss +96 -0
  71. data/components/PanelGroup/PanelGroup.scss.flow +6 -0
  72. data/components/SearchCollectionSelect/SearchCollectionSelect.jsx +29 -0
  73. data/components/SearchCollectionSelect/searchCollectionSelect.scss +0 -0
  74. data/components/Spinner/Spinner.jsx +80 -0
  75. data/components/Spinner/spinner.scss +6 -0
  76. data/components/Spinner/spinner.scss.flow +5 -0
  77. data/components/StepMeter/StepMeter.jsx +75 -0
  78. data/components/StepMeter/step_meter.scss +120 -0
  79. data/components/StepMeter/step_meter.scss.flow +9 -0
  80. data/components/Survey/Survey.jsx +190 -0
  81. data/components/Survey/survey.scss +75 -0
  82. data/components/Survey/survey.scss.flow +11 -0
  83. data/components/Tab/Tab.jsx +70 -0
  84. data/components/Tab/tab.scss +25 -0
  85. data/components/Tab/tab.scss.flow +6 -0
  86. data/components/TabList/TabList.jsx +35 -0
  87. data/components/TabList/tabList.scss +5 -0
  88. data/components/TabList/tabList.scss.flow +5 -0
  89. data/components/Text/Text.jsx +53 -0
  90. data/components/Text/styles.scss +3 -0
  91. data/components/Text/styles.scss.flow +123 -0
  92. data/components/Text/text.scss +35 -0
  93. data/components/TextInput/TextInput.jsx +95 -0
  94. data/components/TextInput/form-control.scss +96 -0
  95. data/components/TextInput/styles.scss +3 -0
  96. data/components/TextInput/styles.scss.flow +7 -0
  97. data/components/TimePicker/TimePicker.jsx +218 -0
  98. data/components/TimePicker/styles.scss +1 -0
  99. data/components/TimePicker/styles.scss.flow +5 -0
  100. data/components/ToggleButton/ToggleButton.jsx +68 -0
  101. data/components/ToggleButton/toggleButton.scss +70 -0
  102. data/components/ToggleButton/toggleButton.scss.flow +14 -0
  103. data/components/UserStamp/UserStamp.jsx +40 -0
  104. data/components/UserStamp/styles.scss +6 -0
  105. data/components/UserStamp/styles.scss.flow +7 -0
  106. data/components/Wip/Wip.jsx +34 -0
  107. data/components/index.js +33 -0
  108. data/components/types.js +21 -0
  109. data/lib/nitro_sg/version.rb +1 -1
  110. metadata +108 -1
@@ -0,0 +1,55 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import classnames from 'classnames'
5
+ import _ from 'lodash'
6
+
7
+ import Text from "../Text/Text"
8
+ import styles from './styles.scss'
9
+ import colors from '../../sass-mixins/base-variables/_colors-export.scss'
10
+
11
+ type Props = {
12
+ children?: Array<React.Node>,
13
+ colors: Object,
14
+ className: string,
15
+ }
16
+
17
+ export default class Color extends React.Component<Props> {
18
+ static defaultProps = {
19
+ className: "",
20
+ colors: colors,
21
+ }
22
+ props: Props
23
+ render() {
24
+ const {
25
+ className,
26
+ colors,
27
+ } = this.props
28
+ const css = [
29
+ className,
30
+ styles['color-swatch'],
31
+ ]
32
+
33
+ const colorMap = new Map(Object.entries(colors));
34
+ let colorList = []
35
+ colorMap.forEach(function(value, key, map) {
36
+ colorList.push(
37
+ <div className="col-sm-2 text-center mb-5" key={value}>
38
+ <div className={classnames(css)} style={{backgroundColor: value }}></div>
39
+ <div className="color-name"><Text color="ink-lighter" size="small">{key}</Text></div>
40
+ <div className="color-value"><Text color="sky-dark" size="smaller">{value}</Text></div>
41
+
42
+ </div>
43
+ )
44
+ });
45
+
46
+ return (
47
+ <div className="container my-5">
48
+ <div className="row">
49
+ {colorList}
50
+ </div>
51
+ </div>
52
+ );
53
+
54
+ }
55
+ }
@@ -0,0 +1,6 @@
1
+ .color-swatch {
2
+ width: 80px;
3
+ height: 80px;
4
+ margin: auto;
5
+ border-radius: 1000px;
6
+ }
@@ -0,0 +1,5 @@
1
+ // @flow
2
+ /* This file is automatically generated by css-modules-flow-types */
3
+ declare module.exports: {|
4
+ +'color-swatch': string;
5
+ |};
@@ -0,0 +1,99 @@
1
+ /* @flow */
2
+
3
+ import React, { Component } from 'react'
4
+ import classnames from 'classnames'
5
+ import { ChromePicker } from 'react-color'
6
+ import { OverlayTrigger, Popover } from 'react-bootstrap'
7
+
8
+ import styles from './colorPickerInput.scss'
9
+
10
+ type Props = {
11
+ className: string,
12
+ color: string,
13
+ disableAlpha: boolean,
14
+ onChange: () => mixed,
15
+ }
16
+
17
+ export default class ColorPickerInput extends Component<Props> {
18
+ static defaultProps = {
19
+ color: '',
20
+ disableAlpha: true,
21
+ onChange: function() {},
22
+ }
23
+
24
+ state = {
25
+ showPicker: false,
26
+ }
27
+
28
+ props: Props
29
+
30
+ handleOnInputFocus = () => {
31
+ this.setState({
32
+ showPicker: true,
33
+ })
34
+ }
35
+
36
+ handleOnInputBlur = () => {
37
+ this.setState({
38
+ showPicker: false,
39
+ })
40
+ }
41
+
42
+ handleOnChange = (e) => {
43
+ this.props.onChange(e.target.value)
44
+ }
45
+
46
+ render() {
47
+ const {
48
+ className,
49
+ color,
50
+ disableAlpha,
51
+ onChange,
52
+ } = this.props
53
+
54
+ const css = classnames([
55
+ className,
56
+ styles['color-picker-input'],
57
+ ])
58
+
59
+ const cancelFocus = (e) => {
60
+ if(e.target.tagName === "INPUT") {
61
+ setTimeout(() => {
62
+ this.setState({showPicker: true})
63
+ }, 100)
64
+ }
65
+ }
66
+
67
+ const popover = (
68
+ <Popover
69
+ className={styles.popover}
70
+ placement="bottom"
71
+ >
72
+ <div onClick={cancelFocus}>
73
+ <ChromePicker
74
+ color={color}
75
+ disableAlpha={disableAlpha}
76
+ onChange={onChange}
77
+ />
78
+ </div>
79
+ </Popover>
80
+ )
81
+
82
+ return (
83
+ <div
84
+ className={css}
85
+ >
86
+ <If condition={this.state.showPicker}>
87
+ {popover}
88
+ </If>
89
+ <input
90
+ onBlur={this.handleOnInputBlur}
91
+ onChange={this.handleOnChange}
92
+ onFocus={this.handleOnInputFocus}
93
+ type="text"
94
+ value={color.hex || color}
95
+ />
96
+ </div>
97
+ )
98
+ }
99
+ }
@@ -0,0 +1,10 @@
1
+ @import "base-variables/_spacing.sass";
2
+
3
+ .color-picker-input {
4
+ position: relative;
5
+ bottom: 0;
6
+ }
7
+
8
+ .popover {
9
+ top: $space-base * 3;
10
+ }
@@ -0,0 +1,6 @@
1
+ // @flow
2
+ /* This file is automatically generated by css-modules-flow-types */
3
+ declare module.exports: {|
4
+ +'color-picker-input': string;
5
+ +'popover': string;
6
+ |};
@@ -0,0 +1,35 @@
1
+ import React from "react"
2
+ import moment from "moment"
3
+ import classnames from "classnames"
4
+ import { DatePicker, Props as DatePickerProps } from "../"
5
+
6
+ import styles from "./styles.scss"
7
+
8
+ export type Props = {
9
+ ...DatePickerProps,
10
+ preventMinor: boolean,
11
+ }
12
+
13
+ const eighteenYearsAgo = moment().subtract(18, "years")
14
+ const isNotMinor = (currentDate, selectedDate) =>
15
+ currentDate.isBefore(eighteenYearsAgo)
16
+
17
+ const DOBInput = ({ className, preventMinor, isValidDate, viewDate, ...props }) => {
18
+ className = classnames(className, styles.dob)
19
+
20
+ if (preventMinor) {
21
+ props.viewDate = viewDate || eighteenYearsAgo
22
+ props.isValidDate = isValidDate || isNotMinor
23
+ }
24
+
25
+ return (
26
+ <DatePicker {...props} className={className} />
27
+ )
28
+ }
29
+
30
+ DOBInput.defaultProps = {
31
+ value: "",
32
+ preventMinor: false,
33
+ }
34
+
35
+ export default DOBInput
@@ -0,0 +1,20 @@
1
+ import React from "react"
2
+ import moment from "moment"
3
+ import DOBInput from "./"
4
+
5
+ import { boolean, text } from "@storybook/addon-knobs"
6
+
7
+ import 'react-datetime/css/react-datetime.css'
8
+
9
+ export default function Story(stories) {
10
+ stories.add("DOBInput", () => {
11
+ const props = {
12
+ preventMinor: boolean("Prevent Minor", true),
13
+ viewDate: text("Default Calendar Date", moment("2000-01-01"))
14
+ }
15
+
16
+ return (
17
+ <DOBInput {...props} />
18
+ )
19
+ })
20
+ }
@@ -0,0 +1,11 @@
1
+ @import "base-mixins/all";
2
+ @import "base-variables/all";
3
+
4
+ .dob {
5
+ :global {
6
+ .rdtDisabled {
7
+ color: $gray-1 !important;
8
+ cursor: not-allowed !important;
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,7 @@
1
+ // @flow
2
+ /* This file is automatically generated by css-modules-flow-types */
3
+ declare module.exports: {|
4
+ +'dob': string;
5
+ +'hidden-xxs': string;
6
+ +'visible-xxs': string;
7
+ |};
@@ -0,0 +1,156 @@
1
+ import React from 'react'
2
+ import classnames from 'classnames'
3
+ import Icon from '../Icon/Icon'
4
+ import {
5
+ FormControl,
6
+ ControlLabel,
7
+ FormGroup,
8
+ InputGroup,
9
+ HelpBlock,
10
+ } from 'react-bootstrap'
11
+
12
+ import moment from 'moment'
13
+ require('moment-timezone')
14
+
15
+ import Datetime from 'react-datetime'
16
+
17
+ import style from './styles.scss'
18
+
19
+ export type Props = {
20
+ className: string,
21
+ errorMessage?: ?string,
22
+ inputProps: Object<{ type: "text" }>,
23
+ isValidDate: () => boolean,
24
+ labelInside: boolean,
25
+ labelText: string,
26
+ multiInput: boolean,
27
+ onChange: (any) => void,
28
+ dateFormat: string,
29
+ timeFormat: string,
30
+ closeOnSelect: boolean,
31
+ timeZone: string,
32
+ required: boolean,
33
+ floatAbove: boolean,
34
+ value: string,
35
+ };
36
+
37
+ export default class DatePicker extends React.Component<Props> {
38
+
39
+ static defaultProps = {
40
+ className: "",
41
+ errorMessage: null,
42
+ inputProps: {
43
+ type: "text",
44
+ },
45
+ onChange: function() {},
46
+ labelInside: true,
47
+ multiInput: false,
48
+ dateFormat: "MM/DD/YYYY",
49
+ closeOnSelect: true,
50
+ timeZone: null,
51
+ }
52
+
53
+ state = {
54
+ valid: true,
55
+ }
56
+ props: Props
57
+
58
+ fieldFormat = () => {
59
+ const { timeFormat, dateFormat } = this.props
60
+ return timeFormat && timeFormat !== "" ? "YYYY-MM-DDTHH:mm:00Z" : dateFormat
61
+ }
62
+
63
+ handleOnChange = (dateTime) => {
64
+ const { timeZone, onChange } = this.props
65
+
66
+ if(dateTime.isValid()) {
67
+ this.setState({ valid: true })
68
+ const date = timeZone ? moment.tz(dateTime) : dateTime
69
+ onChange(date.format(this.fieldFormat()))
70
+ } else {
71
+ this.setState({ valid: false })
72
+ onChange("")
73
+ }
74
+ }
75
+
76
+ renderInput = (inputProps, openCalendar) => {
77
+ const {
78
+ labelText,
79
+ required,
80
+ labelInside,
81
+ errorMessage,
82
+ multiInput,
83
+ } = this.props
84
+
85
+ return (
86
+ <FormGroup
87
+ className={classnames({ 'label-inside': labelInside })}
88
+ validationState={!this.state.valid || errorMessage ? 'error' : undefined}
89
+ >
90
+ <ControlLabel>
91
+ <If condition={required}>{`* `}</If>
92
+ {labelText}
93
+ </ControlLabel>
94
+ <InputGroup>
95
+ <FormControl {...inputProps}/>
96
+ <span
97
+ className={classnames('input-group-addon', { multi: multiInput })}
98
+ onClick={openCalendar}
99
+ >
100
+ <Icon name="calendar"/>
101
+ </span>
102
+ </InputGroup>
103
+ <If condition={errorMessage}>
104
+ <HelpBlock>{errorMessage}</HelpBlock>
105
+ </If>
106
+ </FormGroup>
107
+ )
108
+ }
109
+
110
+ dateTimeProps = () => {
111
+ const {
112
+ className,
113
+ dateFormat,
114
+ timeFormat,
115
+ closeOnSelect,
116
+ timeZone,
117
+ required,
118
+ multiInput,
119
+ floatAbove,
120
+ ...props
121
+ } = this.props
122
+
123
+ const inputProps = this.props.inputProps
124
+ if (required) inputProps.required = "required"
125
+
126
+ return {
127
+ className: classnames(
128
+ className, "react-datetime",
129
+ { 'multi-input-group-item': multiInput, [style.above]: floatAbove }
130
+ ),
131
+ closeOnSelect,
132
+ dateFormat,
133
+ inputProps,
134
+ onChange: this.handleOnChange,
135
+ renderInput: this.renderInput,
136
+ timeFormat,
137
+ timeZone,
138
+ value: this.formattedValue(),
139
+ ...props,
140
+ }
141
+ }
142
+
143
+ formattedValue = () => {
144
+ const { value } = this.props
145
+ if (!value) {
146
+ return ''
147
+ }
148
+ return moment(value).format(this.fieldFormat())
149
+ }
150
+
151
+ render() {
152
+ return (
153
+ <Datetime {...this.dateTimeProps()}/>
154
+ )
155
+ }
156
+ }
@@ -0,0 +1,6 @@
1
+ .above {
2
+ :global .rdtPicker {
3
+ top: auto;
4
+ bottom: 100%;
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ // @flow
2
+ /* This file is automatically generated by css-modules-flow-types */
3
+ declare module.exports: {|
4
+ +'above': string;
5
+ |};
@@ -0,0 +1,109 @@
1
+ import React from "react"
2
+ import classnames from "classnames"
3
+ import moment from "moment"
4
+
5
+ import DatePicker from "../DatePicker/DatePicker"
6
+ import TimePicker from "../TimePicker/TimePicker"
7
+
8
+ import styles from './styles.scss'
9
+
10
+ type Props = {
11
+ className: string,
12
+ datePickerProps: Object<{
13
+ disabled: boolean | "disabled",
14
+ dateFormat: string,
15
+ timeFormat: string,
16
+ }>,
17
+ defaultValue: string | Object,
18
+ onChange: () => mixed,
19
+ timePickerProps: Object<{
20
+ clock: 12 | 24,
21
+ disabled: boolean | "disabled",
22
+ multiGroup: boolean,
23
+ labelInside: boolean,
24
+ }>
25
+ }
26
+
27
+ export default class DateTimePicker extends React.Component<Props> {
28
+
29
+ static defaultProps = {
30
+ className: "",
31
+ datePickerProps: {
32
+ disabled: false,
33
+ dateFormat: "MM/DD/YYYY",
34
+ timeFormat: "",
35
+ },
36
+ defaultValue: null,
37
+ timePickerProps: {
38
+ clock: 12,
39
+ disabled: false,
40
+ multiGroup: true,
41
+ labelInside: true,
42
+ }
43
+ }
44
+
45
+ state = {
46
+ date: null,
47
+ time: null,
48
+ }
49
+
50
+ props: Props
51
+
52
+ formatDateTime = (date, time) => (
53
+ `${date.format(this.props.datePickerProps.dateFormat || "MM/DD/YYYY")} ${time}`
54
+ )
55
+
56
+ handleOnDateChanged = (date) => {
57
+ const {time} = this.state
58
+ this.setState({date})
59
+ if(!time) return
60
+ this.props.onChange(this.formatDateTime(date, time))
61
+ }
62
+
63
+ handleOnTimeChanged = (time) => {
64
+ const {date} = this.state
65
+ this.setState({time})
66
+ if(!date) return
67
+ this.props.onChange(this.formatDateTime(date, time))
68
+ }
69
+
70
+ render() {
71
+ const {
72
+ className,
73
+ datePickerProps,
74
+ defaultValue,
75
+ timePickerProps,
76
+ } = this.props
77
+
78
+ const defaultDate = moment(defaultValue)
79
+ let defaultDateValue
80
+ if (defaultValue) {
81
+ defaultDateValue = defaultDate.isValid() ? defaultDate.format(datePickerProps.dateFormat || "MM/DD/YYYY") : null
82
+ }
83
+
84
+ const css = [
85
+ className,
86
+ styles.dateTimePicker,
87
+ ]
88
+
89
+ return (
90
+ <div className={classnames(css)}>
91
+ <div className="multi-input-group full form-group">
92
+ <DatePicker
93
+ defaultValue={defaultDateValue}
94
+ multiInput
95
+ onChange={this.handleOnDateChanged}
96
+ {...datePickerProps}
97
+ />
98
+ <div className="form-group multi-input-group-item">
99
+ <TimePicker
100
+ defaultValue={defaultValue}
101
+ onChange={this.handleOnTimeChanged}
102
+ {...timePickerProps}
103
+ />
104
+ </div>
105
+ </div>
106
+ </div>
107
+ )
108
+ }
109
+ }