playbook_ui 11.11.0 → 11.12.1.pre.alpha.passphrase1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/index.js +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +21 -1
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +17 -1
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.html.erb +62 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.jsx +86 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_legend_position.md +17 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_button/_button.scss +6 -0
- data/app/pb_kits/playbook/pb_button/docs/_button_default.html.erb +4 -4
- data/app/pb_kits/playbook/pb_button/docs/_button_default.jsx +18 -17
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +15 -0
- data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +16 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.html.erb +86 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.jsx +114 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/_circle_chart_legend_position.md +17 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_circle_chart/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +50 -50
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_time.jsx +1 -0
- data/app/pb_kits/playbook/pb_date_picker/plugins/timeSelect.ts +89 -89
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_time_selection_styles.scss +15 -0
- data/app/pb_kits/playbook/pb_dialog/_dialog.scss +30 -1
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +28 -0
- data/app/pb_kits/playbook/pb_dialog/dialog.rb +7 -35
- data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +21 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_body.html.erb +7 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_body.rb +13 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +13 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_footer.rb +16 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_header.html.erb +13 -0
- data/app/pb_kits/playbook/pb_dialog/dialog_header.rb +3 -20
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.html.erb +12 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_compound_components.md +3 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.html.erb +11 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_default.md +3 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_sizes.html.erb +29 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +3 -1
- data/app/pb_kits/playbook/pb_icon/icon.rb +8 -1
- data/app/pb_kits/playbook/pb_icon/icon.test.js +155 -0
- data/app/pb_kits/playbook/pb_legend/{_legend.jsx → _legend.tsx} +6 -6
- data/app/pb_kits/playbook/pb_legend/legend.test.js +29 -0
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +20 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.html.erb +62 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.jsx +83 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_legend_position.md +17 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_line_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +17 -1
- data/app/pb_kits/playbook/pb_passphrase/_passphrase.jsx +56 -97
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.html.erb +145 -1
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.jsx +127 -3
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.md +11 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.html.erb +136 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.jsx +90 -8
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_common.md +5 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.html.erb +51 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_confirmation.jsx +39 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.html.erb +0 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.jsx +6 -20
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.html.erb +2 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_input_props.jsx +1 -1
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.html.erb +318 -5
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.jsx +134 -48
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.md +11 -5
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.html.erb +123 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.jsx +96 -20
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_strength_change.md +6 -2
- data/app/pb_kits/playbook/pb_passphrase/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_passphrase/passphrase.html.erb +1 -1
- data/app/pb_kits/playbook/pb_passphrase/passphrase.rb +5 -9
- data/app/pb_kits/playbook/pb_passphrase/passphrase.test.jsx +0 -47
- data/app/pb_kits/playbook/pb_radio/_radio.scss +1 -1
- data/app/pb_kits/playbook/pb_title/_title.scss +5 -0
- data/app/pb_kits/playbook/pb_title/_title.tsx +4 -1
- data/app/pb_kits/playbook/pb_title/docs/{_title_light.html.erb → _title_default.html.erb} +3 -3
- data/app/pb_kits/playbook/pb_title/docs/{_title_light.jsx → _title_default.jsx} +14 -14
- data/app/pb_kits/playbook/pb_title/docs/{_title_light.md → _title_default.md} +0 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.html.erb +1 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.jsx +19 -0
- data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.md +4 -0
- data/app/pb_kits/playbook/pb_title/docs/example.yml +4 -2
- data/app/pb_kits/playbook/pb_title/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_title/title.rb +6 -1
- data/app/pb_kits/playbook/pb_title/title.test.js +13 -0
- data/app/pb_kits/playbook/playbook-rails.js +4 -0
- data/app/pb_kits/playbook/plugins/pb_chart.js +13 -0
- data/app/pb_kits/playbook/tokens/_titles.scss +10 -1
- data/app/pb_kits/playbook/tokens/_typography.scss +2 -2
- data/lib/playbook/version.rb +2 -2
- metadata +37 -13
- data/app/pb_kits/playbook/pb_dialog/_dialog.html.erb +0 -10
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.md +0 -1
- data/app/pb_kits/playbook/pb_passphrase/passwordStrength.js +0 -55
- data/app/pb_kits/playbook/pb_passphrase/useHaveIBeenPwned.js +0 -52
- data/app/pb_kits/playbook/pb_passphrase/useZxcvbn.js +0 -58
@@ -1,34 +1,110 @@
|
|
1
1
|
import React, { useState } from 'react'
|
2
|
+
import { useEffect } from 'react'
|
2
3
|
|
3
|
-
import Passphrase from '
|
4
|
-
|
5
|
-
import TextInput from '../../pb_text_input/_text_input'
|
4
|
+
import { Caption, Passphrase, ProgressSimple, TextInput} from '../..'
|
5
|
+
import zxcvbn from 'zxcvbn'
|
6
6
|
|
7
7
|
const PassphraseStrengthChange = (props) => {
|
8
8
|
const [input, setInput] = useState('')
|
9
|
+
const [checkStrength, setCheckStrength] = useState({
|
10
|
+
label: '',
|
11
|
+
percent: 0,
|
12
|
+
score: 0,
|
13
|
+
variant: ''
|
14
|
+
})
|
9
15
|
|
10
16
|
const handleChange = (e) => setInput(e.target.value)
|
11
17
|
|
12
|
-
const
|
13
|
-
|
18
|
+
const handleStrengthCalculation = (settings) => {
|
19
|
+
const {
|
20
|
+
passphrase = "",
|
21
|
+
common = false,
|
22
|
+
isPwned = false,
|
23
|
+
averageThreshold = 2,
|
24
|
+
minLength = 12,
|
25
|
+
strongThreshold = 3,
|
26
|
+
} = settings
|
27
|
+
|
28
|
+
const resultByScore = {
|
29
|
+
0: {
|
30
|
+
variant: 'negative',
|
31
|
+
label: '',
|
32
|
+
percent: 0,
|
33
|
+
},
|
34
|
+
1: {
|
35
|
+
variant: 'negative',
|
36
|
+
label: 'This passphrase is too common',
|
37
|
+
percent: 25,
|
38
|
+
},
|
39
|
+
2: {
|
40
|
+
variant: 'negative',
|
41
|
+
label: 'Too weak',
|
42
|
+
percent: 25,
|
43
|
+
},
|
44
|
+
3: {
|
45
|
+
variant: 'warning',
|
46
|
+
label: 'Almost there, keep going!',
|
47
|
+
percent: 50,
|
48
|
+
},
|
49
|
+
4: {
|
50
|
+
variant: 'positive',
|
51
|
+
label: 'Success! Strong passphrase',
|
52
|
+
percent: 100,
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
const { score } = zxcvbn(passphrase);
|
57
|
+
|
58
|
+
const noPassphrase = passphrase.length <= 0
|
59
|
+
const commonPassphrase = common || isPwned
|
60
|
+
const weakPassphrase = passphrase.length < minLength || score < averageThreshold
|
61
|
+
const averagePassphrase = score < strongThreshold
|
62
|
+
const strongPassphrase = score >= strongThreshold
|
63
|
+
|
64
|
+
if (noPassphrase) {
|
65
|
+
return {...resultByScore[0], score}
|
66
|
+
} else if (commonPassphrase) {
|
67
|
+
return {...resultByScore[1], score}
|
68
|
+
} else if (weakPassphrase) {
|
69
|
+
return {...resultByScore[2], score}
|
70
|
+
} else if (averagePassphrase){
|
71
|
+
return {...resultByScore[3], score}
|
72
|
+
} else if (strongPassphrase) {
|
73
|
+
return {...resultByScore[4], score}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
useEffect(() => {
|
78
|
+
const result = handleStrengthCalculation({ passphrase: input })
|
79
|
+
setCheckStrength({...result})
|
80
|
+
},[input])
|
14
81
|
|
15
82
|
return (
|
16
83
|
<>
|
17
|
-
<
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
84
|
+
<Passphrase
|
85
|
+
label="Passphrase"
|
86
|
+
onChange={handleChange}
|
87
|
+
value={input}
|
88
|
+
{...props}
|
89
|
+
/>
|
90
|
+
{input.length > 0 && (
|
91
|
+
<>
|
92
|
+
<ProgressSimple
|
93
|
+
percent={checkStrength.percent}
|
94
|
+
variant={checkStrength.variant}
|
95
|
+
/>
|
96
|
+
<Caption size='xs'
|
97
|
+
text={checkStrength.label}
|
98
|
+
/>
|
99
|
+
</>
|
100
|
+
)}
|
101
|
+
<TextInput
|
102
|
+
disabled
|
103
|
+
label="Passphrase Strength"
|
104
|
+
marginTop="xl"
|
105
|
+
readOnly
|
106
|
+
value={checkStrength.score}
|
107
|
+
/>
|
32
108
|
</>
|
33
109
|
)
|
34
110
|
}
|
@@ -1,3 +1,7 @@
|
|
1
|
-
|
1
|
+
Strength is calculated on a 0-4 scale by the <a href="https://github.com/dropbox/zxcvbn" target="_blank"> Zxcvbn package</a>.
|
2
2
|
|
3
|
-
|
3
|
+
<div class="pb_pill_kit_warning"><div class="pb_title_kit_size_4 pb_pill_text">Disclaimer</div></div>
|
4
|
+
|
5
|
+
This example depends on the `zxcvbn` library.
|
6
|
+
|
7
|
+
You can use any library to achieve the same result, this example only intends to show how to add more features to the `Passphrase` kit.
|
@@ -2,13 +2,17 @@ examples:
|
|
2
2
|
|
3
3
|
rails:
|
4
4
|
- passphrase_default: Default
|
5
|
+
- passphrase_confirmation: Confirmation
|
5
6
|
- passphrase_meter_settings: Meter Settings
|
6
7
|
- passphrase_input_props: Input Props
|
7
8
|
- passphrase_tips: Tips
|
9
|
+
- passphrase_strength_change: Strength Change
|
10
|
+
- passphrase_common: Common Passphrases
|
8
11
|
- passphrase_breached: Breached Passphrases
|
9
12
|
|
10
13
|
react:
|
11
14
|
- passphrase_default: Default
|
15
|
+
- passphrase_confirmation: Confirmation
|
12
16
|
- passphrase_meter_settings: Meter Settings
|
13
17
|
- passphrase_input_props: Input Props
|
14
18
|
- passphrase_tips: Tips
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export { default as PassphraseDefault } from './_passphrase_default.jsx'
|
2
|
+
export { default as PassphraseConfirmation } from './_passphrase_confirmation.jsx'
|
2
3
|
export { default as PassphraseMeterSettings } from './_passphrase_meter_settings'
|
3
4
|
export { default as PassphraseInputProps } from './_passphrase_input_props'
|
4
5
|
export { default as PassphraseTips } from './_passphrase_tips'
|
@@ -1 +1 @@
|
|
1
|
-
<%= react_component('Passphrase', object.passphrase_options) %>
|
1
|
+
<%= react_component('Passphrase', object.passphrase_options, class: object.classname,) %>
|
@@ -3,15 +3,14 @@
|
|
3
3
|
module Playbook
|
4
4
|
module PbPassphrase
|
5
5
|
class Passphrase < Playbook::KitBase
|
6
|
-
prop :average_threshold
|
7
|
-
prop :check_pwned
|
8
6
|
prop :confirmation, type: Playbook::Props::Boolean, default: false
|
9
7
|
prop :input_props, type: Playbook::Props::Hash, default: {}
|
10
8
|
prop :label
|
11
|
-
prop :
|
12
|
-
|
13
|
-
|
9
|
+
prop :show_tips_below, type: Playbook::Props::Enum,
|
10
|
+
values: %w[always xs sm md lg xl],
|
11
|
+
default: "always"
|
14
12
|
prop :tips, type: Playbook::Props::Array, default: []
|
13
|
+
prop :value, type: Playbook::Props::String
|
15
14
|
|
16
15
|
def classname
|
17
16
|
generate_classname("pb_passphrase")
|
@@ -19,18 +18,15 @@ module Playbook
|
|
19
18
|
|
20
19
|
def passphrase_options
|
21
20
|
{
|
22
|
-
checkPwned: check_pwned,
|
23
21
|
dark: dark,
|
24
22
|
id: id,
|
25
|
-
averageThreshold: average_threshold,
|
26
23
|
confirmation: confirmation,
|
27
24
|
inputProps: input_props,
|
28
25
|
label: label,
|
29
|
-
minLength: min_length,
|
30
26
|
showTipsBelow: show_tips_below,
|
31
|
-
strongThreshold: strong_threshold,
|
32
27
|
tips: tips,
|
33
28
|
uncontrolled: true,
|
29
|
+
value: value,
|
34
30
|
}.compact
|
35
31
|
end
|
36
32
|
end
|
@@ -64,41 +64,6 @@ test('passes input props to input element', () => {
|
|
64
64
|
expect(input).toBeDisabled()
|
65
65
|
})
|
66
66
|
|
67
|
-
test('progress bar is invisible when value is empty', () => {
|
68
|
-
render(
|
69
|
-
<Passphrase
|
70
|
-
data={{ testid: testId }}
|
71
|
-
/>
|
72
|
-
)
|
73
|
-
|
74
|
-
const kit = screen.getByTestId(testId)
|
75
|
-
expect(kit.querySelector('[class^=pb_progress_simple_wrapper]')).toHaveClass('progress-empty-input')
|
76
|
-
})
|
77
|
-
|
78
|
-
test('progress bar is visible when value is not empty', () => {
|
79
|
-
render(
|
80
|
-
<Passphrase
|
81
|
-
data={{ testid: testId }}
|
82
|
-
value="test_password_input"
|
83
|
-
/>
|
84
|
-
)
|
85
|
-
|
86
|
-
const kit = screen.getByTestId(testId)
|
87
|
-
expect(kit.querySelector('[class^=pb_progress_simple_wrapper]')).not.toHaveClass('progress-empty-input')
|
88
|
-
})
|
89
|
-
|
90
|
-
test('no progress bar is show when confirmation is true', () => {
|
91
|
-
render(
|
92
|
-
<Passphrase
|
93
|
-
confirmation
|
94
|
-
data={{ testid: testId }}
|
95
|
-
/>
|
96
|
-
)
|
97
|
-
|
98
|
-
const kit = screen.getByTestId(testId)
|
99
|
-
expect(kit.querySelector('[class^=pb_progress_simple_wrapper]')).toBeNull()
|
100
|
-
})
|
101
|
-
|
102
67
|
test('popover target shows when tips are given', () => {
|
103
68
|
render(
|
104
69
|
<Passphrase
|
@@ -121,15 +86,3 @@ test('popover target does not show when tips are not given', () => {
|
|
121
86
|
const kit = screen.getByTestId(testId)
|
122
87
|
expect(kit.querySelector('[class^=pb_popover_reference_wrapper]')).toBeNull()
|
123
88
|
})
|
124
|
-
|
125
|
-
test('data-strength attribute exposes strength of password', () => {
|
126
|
-
render(
|
127
|
-
<Passphrase
|
128
|
-
data={{ testid: testId }}
|
129
|
-
value="correct horse battery staple"
|
130
|
-
/>
|
131
|
-
)
|
132
|
-
|
133
|
-
const kit = screen.getByTestId(testId)
|
134
|
-
expect(parseInt(kit.getAttribute('data-strength'))).toBeGreaterThan(0)
|
135
|
-
})
|
@@ -5,6 +5,7 @@ import { deprecatedProps, GlobalProps, globalProps } from '../utilities/globalPr
|
|
5
5
|
|
6
6
|
type TitleProps = {
|
7
7
|
aria?: {[key: string]: string},
|
8
|
+
bold?: boolean,
|
8
9
|
children?: React.ReactChild[] | React.ReactChild,
|
9
10
|
className?: string,
|
10
11
|
color?: "default" | "light" | "lighter" | "success" | "error" | "link",
|
@@ -20,6 +21,7 @@ const Title = (props: TitleProps): React.ReactElement => {
|
|
20
21
|
if (props.variant) deprecatedProps('Title', ['variant']) //variant prop is deprecated, use color instead
|
21
22
|
const {
|
22
23
|
aria = {},
|
24
|
+
bold = true,
|
23
25
|
children,
|
24
26
|
className,
|
25
27
|
color,
|
@@ -33,8 +35,9 @@ const Title = (props: TitleProps): React.ReactElement => {
|
|
33
35
|
|
34
36
|
const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
|
35
37
|
const dataProps: {[key: string]: string | number} = buildDataProps(data)
|
38
|
+
const getBold = bold ? '' : 'thin'
|
36
39
|
const classes = classnames(
|
37
|
-
buildCss('pb_title_kit', `size_${size}`, variant, color),
|
40
|
+
buildCss('pb_title_kit', `size_${size}`, variant, color, getBold),
|
38
41
|
globalProps(props),
|
39
42
|
className,
|
40
43
|
)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<br/>
|
7
7
|
|
8
|
-
<%= pb_rails("title", props: { text: "Title 4", tag: "h4", size: 4 }) %>
|
9
|
-
<%= pb_rails("title", props: { text: "Title 3", tag: "h3", size: 3 }) %>
|
10
|
-
<%= pb_rails("title", props: { text: "Title 2", tag: "h2", size: 2 }) %>
|
11
8
|
<%= pb_rails("title", props: { text: "Title 1", tag: "h1", size: 1 }) %>
|
9
|
+
<%= pb_rails("title", props: { text: "Title 2", tag: "h2", size: 2 }) %>
|
10
|
+
<%= pb_rails("title", props: { text: "Title 3", tag: "h3", size: 3 }) %>
|
11
|
+
<%= pb_rails("title", props: { text: "Title 4", tag: "h4", size: 4 }) %>
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
2
2
|
|
3
3
|
import Title from '../_title'
|
4
4
|
|
5
|
-
const
|
5
|
+
const TitleDefault = (props) => {
|
6
6
|
return (
|
7
7
|
<div>
|
8
8
|
<Title
|
@@ -11,15 +11,9 @@ const TitleLight = (props) => {
|
|
11
11
|
/>
|
12
12
|
<br />
|
13
13
|
<Title
|
14
|
-
size={
|
15
|
-
tag="
|
16
|
-
text="Title
|
17
|
-
{...props}
|
18
|
-
/>
|
19
|
-
<Title
|
20
|
-
size={3}
|
21
|
-
tag="h3"
|
22
|
-
text="Title 3"
|
14
|
+
size={1}
|
15
|
+
tag="h1"
|
16
|
+
text="Title 1"
|
23
17
|
{...props}
|
24
18
|
/>
|
25
19
|
<Title
|
@@ -29,13 +23,19 @@ const TitleLight = (props) => {
|
|
29
23
|
{...props}
|
30
24
|
/>
|
31
25
|
<Title
|
32
|
-
size={
|
33
|
-
tag="
|
34
|
-
text="Title
|
26
|
+
size={3}
|
27
|
+
tag="h3"
|
28
|
+
text="Title 3"
|
29
|
+
{...props}
|
30
|
+
/>
|
31
|
+
<Title
|
32
|
+
size={4}
|
33
|
+
tag="h4"
|
34
|
+
text="Title 4"
|
35
35
|
{...props}
|
36
36
|
/>
|
37
37
|
</div>
|
38
38
|
)
|
39
39
|
}
|
40
40
|
|
41
|
-
export default
|
41
|
+
export default TitleDefault
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= pb_rails("title", props: { text: "Title 1", tag: "h1", size: 1, bold: false }) %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
import Title from '../_title'
|
4
|
+
|
5
|
+
const TitleLightWeight = (props) => {
|
6
|
+
return (
|
7
|
+
<div>
|
8
|
+
<Title
|
9
|
+
bold={false}
|
10
|
+
size={1}
|
11
|
+
tag="h1"
|
12
|
+
text="Title 1"
|
13
|
+
{...props}
|
14
|
+
/>
|
15
|
+
</div>
|
16
|
+
)
|
17
|
+
}
|
18
|
+
|
19
|
+
export default TitleLightWeight
|
@@ -0,0 +1,4 @@
|
|
1
|
+
##### Prop
|
2
|
+
Title `size 1` will use `font-weight: 700` by default, if you want a lighter font weight, use the `bold` prop set to `false`.
|
3
|
+
Title `size 2` & `size 3` uses a light font weight by default and will not accept a bold font weight.
|
4
|
+
Title `size 4` uses a heavy font weight by default and will not accept a lighter font weight.
|
@@ -1,8 +1,10 @@
|
|
1
1
|
examples:
|
2
2
|
rails:
|
3
|
-
-
|
3
|
+
- title_default: Default UI
|
4
|
+
- title_light_weight: Light Weight UI
|
4
5
|
- title_colors: Colors
|
5
6
|
|
6
7
|
react:
|
7
|
-
-
|
8
|
+
- title_default: Default UI
|
9
|
+
- title_light_weight: Light Weight UI
|
8
10
|
- title_colors: Colors
|
@@ -17,9 +17,14 @@ module Playbook
|
|
17
17
|
values: [nil, "link"],
|
18
18
|
default: nil,
|
19
19
|
deprecated: true
|
20
|
+
prop :bold, type: Playbook::Props::Boolean, default: true
|
20
21
|
|
21
22
|
def classname
|
22
|
-
generate_classname("pb_title_kit", size, variant, color)
|
23
|
+
generate_classname("pb_title_kit", size, variant, color, is_bold)
|
24
|
+
end
|
25
|
+
|
26
|
+
def is_bold
|
27
|
+
bold ? nil : "thin"
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
@@ -15,6 +15,19 @@ test('returns namespaced class name', () => {
|
|
15
15
|
expect(kit).toHaveClass('pb_title_kit_size_3')
|
16
16
|
})
|
17
17
|
|
18
|
+
test('with thin font weight', () => {
|
19
|
+
render(
|
20
|
+
<Title
|
21
|
+
bold={false}
|
22
|
+
data={{ testid: 'primary-test' }}
|
23
|
+
text="Test thin font weight"
|
24
|
+
/>
|
25
|
+
)
|
26
|
+
|
27
|
+
const kit = screen.getByTestId('primary-test')
|
28
|
+
expect(kit).toHaveClass('pb_title_kit_size_3_thin')
|
29
|
+
})
|
30
|
+
|
18
31
|
test('with colors', () => {
|
19
32
|
render(
|
20
33
|
<Title
|
@@ -9,6 +9,10 @@ import './pb_form/pb_form_validation'
|
|
9
9
|
import datePickerHelper from './pb_date_picker/date_picker_helper'
|
10
10
|
window.datePickerHelper = datePickerHelper
|
11
11
|
|
12
|
+
// Dialog
|
13
|
+
import dialogHelper from './pb_dialog/dialogHelper'
|
14
|
+
window.dialogHelper = dialogHelper
|
15
|
+
|
12
16
|
// Lazy image loading
|
13
17
|
import 'lazysizes'
|
14
18
|
|
@@ -167,6 +167,14 @@ class pbChart {
|
|
167
167
|
},
|
168
168
|
},
|
169
169
|
|
170
|
+
legend: {
|
171
|
+
align: this.defaults.align,
|
172
|
+
verticalAlign: this.defaults.verticalAlign,
|
173
|
+
layout: this.defaults.layout,
|
174
|
+
x: this.defaults.x,
|
175
|
+
y: this.defaults.y,
|
176
|
+
},
|
177
|
+
|
170
178
|
plotOptions: {
|
171
179
|
pie: {
|
172
180
|
colors: options.colors.length > 0 ? mapColors(options.colors) : highchartsTheme.colors,
|
@@ -255,6 +263,11 @@ class pbChart {
|
|
255
263
|
},
|
256
264
|
legend: {
|
257
265
|
enabled: this.defaults.legend,
|
266
|
+
align: this.defaults.align,
|
267
|
+
verticalAlign: this.defaults.verticalAlign,
|
268
|
+
layout: this.defaults.layout,
|
269
|
+
x: this.defaults.x,
|
270
|
+
y: this.defaults.y,
|
258
271
|
},
|
259
272
|
colors: options.colors !== undefined && options.colors.length > 0 ? mapColors(options.colors) : highchartsTheme.colors,
|
260
273
|
plotOptions: {
|
@@ -18,7 +18,6 @@
|
|
18
18
|
|
19
19
|
@mixin pb_title_1 {
|
20
20
|
@include pb_title($heading_1);
|
21
|
-
letter-spacing: -0.03em;
|
22
21
|
}
|
23
22
|
|
24
23
|
@mixin pb_title_2 {
|
@@ -31,8 +30,18 @@
|
|
31
30
|
|
32
31
|
@mixin pb_title_4 {
|
33
32
|
@include pb_title($heading_4, $bolder);
|
33
|
+
letter-spacing: -0.03em;
|
34
34
|
}
|
35
35
|
|
36
36
|
@mixin pb_title_dark {
|
37
37
|
color: $text_dk_default;
|
38
38
|
}
|
39
|
+
|
40
|
+
@mixin pb_title_bold {
|
41
|
+
font-weight: $bolder;
|
42
|
+
}
|
43
|
+
|
44
|
+
@mixin pb_title_thin {
|
45
|
+
font-weight: $lighter;
|
46
|
+
letter-spacing: $lspace_tight;
|
47
|
+
}
|
@@ -30,7 +30,7 @@ $text_smallest: $font_smallest;
|
|
30
30
|
|
31
31
|
|
32
32
|
/* Headings */
|
33
|
-
$heading_1:
|
33
|
+
$heading_1: 46px;
|
34
34
|
$heading_2: 34px;
|
35
35
|
$heading_3: $font_larger;
|
36
36
|
$heading_4: $font_base;
|
@@ -41,7 +41,7 @@ $heading_4: $font_base;
|
|
41
41
|
// Letter Spacing
|
42
42
|
$lspace_tightest: -.1em;
|
43
43
|
$lspace_tighter: -.07em;
|
44
|
-
$lspace_tight: -.
|
44
|
+
$lspace_tight: -.01em;
|
45
45
|
$lspace_normal: 0;
|
46
46
|
$lspace_loose: .03em;
|
47
47
|
$lspace_looser: .07em;
|
data/lib/playbook/version.rb
CHANGED