playbook_ui 13.18.0.pre.alpha.play1141iconkitusinglibrary2210 → 13.18.0.pre.alpha.powercentrainplaybookpt22201

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 678dcc3bb0c0838d369b7a2ff9415d8446cc40e2d1fa15c9ba95c85f266317c0
4
- data.tar.gz: ca825e466b46de23eb9eef86ad9b43f50c7243654e7bcc696fd1a4941916d405
3
+ metadata.gz: e3b922118d0b871f7207a63dfcca6202da7b077b9d3d5c43cabae7aa8c7d1466
4
+ data.tar.gz: 2a1a35a01923c0c19bc00fdbe33968bd6561ad16c99a1e79ecc98a6d1005b659
5
5
  SHA512:
6
- metadata.gz: 426ae3a6e11f5bb0cf0f8fa80cbddd703cc3e707ff22d2665644ee4d4e164e728da2ee3616425ea5e2672d73f9d8d5cfdc0c339fa207e71f9dc88ac957ae11af
7
- data.tar.gz: a4d764a8f2f14a37eca3baf54c35f4bce8bc3f65baa340e0d57263c308f6452c7144d8279e53fe7a7edf8618af3d267a2a1022fbcc6cdacf45fc58a6224a0a17
6
+ metadata.gz: 1caa21aff0eef77479226d387147d1aaa75da7086a8cb9563ccf138e5165bf2528dd6c26cf4c273e4ab3b6706968d0dda029bd4003d1f249253dd13bb8a7ee8f
7
+ data.tar.gz: ae88cb3b68a66351ea7c90b5477e9672c82f6376074ea37446afd33c637ce66c311456047873126562ea4487bcda82788f15381b6caa3360804a06023e1cca62
@@ -6,9 +6,9 @@
6
6
  @import "../tokens/typography";
7
7
 
8
8
  $pb_button_sizes: (
9
- "sm": 0.75rem,
10
- "md": 0.875rem,
11
- "lg": 1.125rem,
9
+ "sm": $font_smaller,
10
+ "md": $font_small,
11
+ "lg": ($font_large - 2px),
12
12
  );
13
13
 
14
14
  [class*=pb_button_kit]{
@@ -9,7 +9,7 @@
9
9
 
10
10
  $pb_button_size: 40px;
11
11
  $pb_button_v_padding: 7px;
12
- $pb_button_h_padding: 34px;
12
+ $pb_button_h_padding: 28px;
13
13
  $pb_button_hover_darken: 4%;
14
14
  $pb_button_border_width: 0px;
15
15
 
@@ -27,12 +27,13 @@ $pb_button_border_width: 0px;
27
27
  text-rendering: optimizeLegibility;
28
28
  font-size: $font_small;
29
29
  font-weight: $bold;
30
+ letter-spacing: $lspace_loose;
30
31
  text-align: center;
31
32
  vertical-align: middle;
32
33
  text-transform: none;
33
34
  border-width: $pb_button_border_width;
34
35
  border-style: solid;
35
- border-radius: $border_rad_light;
36
+ border-radius: $border_rad_heavy;
36
37
  min-height: $pb_button_size;
37
38
  line-height: 1.5;
38
39
  padding: $pb_button_v_padding $pb_button_h_padding;
@@ -24,7 +24,7 @@ $pb_dark_caption_colors: (
24
24
  color: $text_lt_light;
25
25
  text-transform: uppercase;
26
26
  font-size: $font_size;
27
- letter-spacing: $lspace_looser;
27
+ letter-spacing: $lspace_loosest;
28
28
  }
29
29
 
30
30
  @mixin caption_color($color: $text_lt_light) {
@@ -53,7 +53,7 @@ const adjustAxisStyle = (axis) => {
53
53
  /* Change axis label styles */
54
54
  axis.labels.style.fontFamily = typography.font_family_base
55
55
  axis.labels.style.color = colors.charcoal
56
- axis.labels.style.fontWeight = typography.light
56
+ axis.labels.style.fontWeight = typography.regular
57
57
  axis.labels.style.fontSize = typography.font_small
58
58
  }
59
59
 
@@ -27,7 +27,7 @@ const highchartsDarkTheme: ThemeProps = {
27
27
  style: {
28
28
  color: colors.text_dk_default,
29
29
  fontFamily: typography.font_family_base,
30
- fontWeight: typography.regular,
30
+ fontWeight: typography.bold,
31
31
  fontSize: typography.heading_3,
32
32
  },
33
33
  },
@@ -27,7 +27,7 @@ const highchartsTheme: ThemeProps = {
27
27
  style: {
28
28
  color: colors.text_lt_default,
29
29
  fontFamily: typography.font_family_base,
30
- fontWeight: typography.regular,
30
+ fontWeight: typography.bold,
31
31
  fontSize: typography.heading_3,
32
32
  },
33
33
  },
@@ -55,7 +55,7 @@ $form_pill_colors: (
55
55
  height: fit-content;
56
56
  height: -moz-fit-content;
57
57
  .pb_form_pill_text, .pb_form_pill_close, .pb_form_pill_tag {
58
- font-size: 16px;
58
+ font-size: $font_base;
59
59
  font-weight: $regular;
60
60
  }
61
61
  .pb_form_pill_text, .pb_form_pill_tag {
@@ -1,4 +1,4 @@
1
- import React, { ReactSVGElement } from 'react'
1
+ import React from 'react'
2
2
  import classnames from 'classnames'
3
3
  import { buildAriaProps, buildDataProps, buildHtmlProps } from '../utilities/props'
4
4
  import { GlobalProps, globalProps } from '../utilities/globalProps'
@@ -27,7 +27,7 @@ type IconProps = {
27
27
  data?: {[key: string]: string},
28
28
  fixedWidth?: boolean,
29
29
  flip?: "horizontal" | "vertical" | "both" | "none",
30
- icon: string | ReactSVGElement,
30
+ icon: string,
31
31
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
32
32
  id?: string,
33
33
  inverse?: boolean,
@@ -47,11 +47,6 @@ const flipMap = {
47
47
  none: ""
48
48
  }
49
49
 
50
- declare global {
51
- // eslint-disable-next-line no-var
52
- var PB_ICONS: {[key: string]: React.FunctionComponent<any>}
53
- }
54
-
55
50
  const Icon = (props: IconProps) => {
56
51
  const {
57
52
  aria = {},
@@ -62,7 +57,7 @@ const Icon = (props: IconProps) => {
62
57
  fixedWidth = true,
63
58
  flip = "none",
64
59
  htmlOptions = {},
65
- icon = "",
60
+ icon,
66
61
  id,
67
62
  inverse = false,
68
63
  listItem = false,
@@ -74,8 +69,6 @@ const Icon = (props: IconProps) => {
74
69
  spin = false,
75
70
  } = props
76
71
 
77
- let iconElement: ReactSVGElement | null = typeof(icon) === "object" ? icon : null
78
-
79
72
  const faClasses = {
80
73
  'fa-border': border,
81
74
  'fa-fw': fixedWidth,
@@ -86,23 +79,19 @@ const Icon = (props: IconProps) => {
86
79
  [`fa-${size}`]: size,
87
80
  [`fa-pull-${pull}`]: pull,
88
81
  [`fa-rotate-${rotation}`]: rotation,
89
- }
90
-
91
- if (!customIcon && !iconElement) {
92
- const PowerIcon: React.FunctionComponent<any> | undefined =
93
- window.PB_ICONS ? window.PB_ICONS[icon as string] : null
94
82
 
95
- if (PowerIcon) {
96
- iconElement = <PowerIcon /> as ReactSVGElement
97
- } else {
98
- faClasses[`fa-${icon}`] = icon as string
99
- }
100
83
  }
101
84
 
85
+ // Lets check and see if the icon prop is referring to a custom Power icon...
86
+ // If so, then set fa-icon to "custom"
87
+ // this ensures the JS will not do any further operations
88
+ // faClasses[`fa-${icon}`] = customIcon ? 'custom' : icon
89
+ if (!customIcon) faClasses[`fa-${icon}`] = icon
90
+
102
91
  const classes = classnames(
103
92
  flipMap[flip],
104
- (!iconElement && !customIcon) ? 'pb_icon_kit' : '',
105
- (iconElement || customIcon) ? 'pb_custom_icon' : fontStyle,
93
+ 'pb_icon_kit',
94
+ customIcon ? '' : fontStyle,
106
95
  faClasses,
107
96
  globalProps(props),
108
97
  className
@@ -121,22 +110,20 @@ const Icon = (props: IconProps) => {
121
110
 
122
111
  // Add a conditional here to show only the SVG if custom
123
112
  const displaySVG = (customIcon: any) => {
124
- if (iconElement || customIcon)
113
+ if (customIcon)
125
114
  return (
126
115
  <>
127
116
  {
128
- React.cloneElement(iconElement || customIcon, {
117
+ React.cloneElement(customIcon, {
129
118
  ...dataProps,
130
119
  ...htmlProps,
131
120
  className: classes,
132
121
  id,
133
- width: 'auto',
134
- height: 'auto',
135
122
  })
136
123
  }
137
124
  </>
138
125
  )
139
- else if (isValidEmoji(icon as string))
126
+ else if (isValidEmoji(icon))
140
127
  return (
141
128
  <>
142
129
  <span
@@ -149,6 +136,7 @@ const Icon = (props: IconProps) => {
149
136
  </span>
150
137
  </>
151
138
  )
139
+
152
140
  else
153
141
  return (
154
142
  <>
@@ -173,4 +161,4 @@ const Icon = (props: IconProps) => {
173
161
  )
174
162
  }
175
163
 
176
- export default Icon
164
+ export default Icon
@@ -2,9 +2,15 @@
2
2
  <div class="icon-wrapper">
3
3
 
4
4
  <% svg_url = "https://upload.wikimedia.org/wikipedia/commons/3/3b/Wrench_font_awesome.svg" %>
5
- <p><%= pb_rails("icon", props: { icon: svg_url } ) %></p>
6
- <p><%= pb_rails("icon", props: { rotation: 90, icon: svg_url, size: "2x" } ) %></p>
7
- <p><%= pb_rails("icon", props: { spin: true, icon: svg_url, size: "3x" } ) %></p>
8
- <p><%= pb_rails("icon", props: { size: "5x", icon: svg_url } ) %></p>
9
- <p><%= pb_rails("icon", props: { flip: "horizontal", size: "5x", icon: svg_url } ) %></p>
5
+ <p><%= pb_rails("icon", props: { custom_icon: svg_url } ) %></p>
6
+ <p><%= pb_rails("icon", props: { rotation: 90, custom_icon: svg_url, size: "2x" } ) %></p>
7
+ <p><%= pb_rails("icon", props: { spin: true, custom_icon: svg_url, size: "3x" } ) %></p>
8
+ <p><%= pb_rails("icon", props: { size: "5x", custom_icon: svg_url } ) %></p>
9
+ <p><%= pb_rails("icon", props: { flip: "horizontal", size: "5x", custom_icon: svg_url } ) %></p>
10
+
11
+ <%= pb_rails("body", props: {
12
+ text: "Custom icons are compatible with other icon props (size, rotation,
13
+ spin, flip, etc). Their SVG fill colors will be inherited from
14
+ parent element's css color properties."
15
+ } ) %>
10
16
  </div>
@@ -1,59 +1,33 @@
1
1
  import React from 'react'
2
2
  import { Icon } from '../../'
3
3
 
4
+ // import Icons as config from 'power-icons'
4
5
  const config = {
5
- icon: (
6
- <svg viewBox="0 -256 1792 1792"
6
+ moon: (
7
+ <svg
8
+ ariaHidden="true"
9
+ focusable="false"
10
+ role="img"
11
+ viewBox="0 0 512 512"
7
12
  xmlns="http://www.w3.org/2000/svg"
8
13
  >
9
- <g transform="matrix(1,0,0,-1,53.152542,1217.0847)">
10
- <path d="m 384,64 q 0,26 -19,45 -19,19 -45,19 -26,0 -45,-19 -19,-19 -19,-45 0,-26 19,-45 19,-19 45,-19 26,0 45,19 19,19 19,45 z m 644,420 -682,-682 q -37,-37 -90,-37 -52,0 -91,37 L 59,-90 Q 21,-54 21,0 21,53 59,91 L 740,772 Q 779,674 854.5,598.5 930,523 1028,484 z m 634,435 q 0,-39 -23,-106 Q 1592,679 1474.5,595.5 1357,512 1216,512 1031,512 899.5,643.5 768,775 768,960 q 0,185 131.5,316.5 131.5,131.5 316.5,131.5 58,0 121.5,-16.5 63.5,-16.5 107.5,-46.5 16,-11 16,-28 0,-17 -16,-28 L 1152,1120 V 896 l 193,-107 q 5,3 79,48.5 74,45.5 135.5,81 61.5,35.5 70.5,35.5 15,0 23.5,-10 8.5,-10 8.5,-25 z" />
11
- </g>
14
+ <path
15
+ d="M448 0H64C28.7 0 0 28.7 0 64v288c0 35.3 28.7 64 64 64h96v84c0 7.1 5.8 12 12 12 2.4 0 4.9-.7 7.1-2.4L304 416h144c35.3 0 64-28.7 64-64V64c0-35.3-28.7-64-64-64zm16 352c0 8.8-7.2 16-16 16H288l-12.8 9.6L208 428v-60H64c-8.8 0-16-7.2-16-16V64c0-8.8 7.2-16 16-16h384c8.8 0 16 7.2 16 16v288zM336 184h-56v-56c0-8.8-7.2-16-16-16h-16c-8.8 0-16 7.2-16 16v56h-56c-8.8 0-16 7.2-16 16v16c0 8.8 7.2 16 16 16h56v56c0 8.8 7.2 16 16 16h16c8.8 0 16-7.2 16-16v-56h56c8.8 0 16-7.2 16-16v-16c0-8.8-7.2-16-16-16z"
16
+ fill="currentColor"
17
+ />
12
18
  </svg>
13
19
  ),
14
20
  }
15
21
 
16
22
  const IconCustom = (props) => {
17
23
  return (
18
- <React.Fragment>
19
- <p>
20
- <Icon
21
- icon={config.icon}
22
- {...props}
23
- />
24
- </p>
25
- <p>
26
- <Icon
27
- icon={config.icon}
28
- rotation={90}
29
- size="2x"
30
- {...props}
31
- />
32
- </p>
33
- <p>
34
- <Icon
35
- icon={config.icon}
36
- size="3x"
37
- spin
38
- {...props}
39
- />
40
- </p>
41
- <p>
42
- <Icon
43
- icon={config.icon}
44
- size="5x"
45
- {...props}
46
- />
47
- </p>
48
- <p>
49
- <Icon
50
- flip="horizontal"
51
- icon={config.icon}
52
- size="5x"
53
- {...props}
54
- />
55
- </p>
56
- </React.Fragment>
24
+ <div>
25
+ <Icon
26
+ customIcon={config.moon}
27
+ size="7x"
28
+ {...props}
29
+ />
30
+ </div>
57
31
  )
58
32
  }
59
33
 
@@ -4,12 +4,16 @@ When using custom icons it is important to introduce a "clean" SVG. In order to
4
4
 
5
5
  Attributes must be React compatible e.g. <code>xmlns:xlink</code> should be <code>xmlnsXlink</code> and so on. <strong>There should be no hyphenated attributes and no semi-colons!.</strong>
6
6
 
7
- Fill colors with regards to <code>g</code> or <code>path</code> nodes, e.g. <code>fill="black"</code>, should be replaced with <code>currentColor</code> ala <code>fill="currentColor"</code>. Your mileage may vary depending on the complexity of your SVG.
7
+ Fill colors with regards to <code>g</code> or <code>path</code> nodes, e.g. <code>fill="black"</code>, should be replaced with <code>currentColor</code> ala <code>fill="currentColor"</code>. Your mileage may vary depending on the complexity of your SVG.
8
8
 
9
- Pay attention to your custom icon's dimensions and `viewBox` attribute. It is best to use a `viewBox="0 0 512 512"` starting point **when designing instead of trying to retrofit the viewbox afterwards**!
9
+ Pay attention to your custom icon's dimensions and `viewBox` attribute. It is best to use a `viewBox="0 0 512 512"` starting point __when designing instead of trying to retrofit the viewbox afterwards__!
10
10
 
11
- You must source _your own SVG into component/view_ you are working on. This can easily be done in programmatic and maintainable ways.
11
+ You must source *your own SVG into component/view* you are working on. This can easily be done in programmatic and maintainable ways.
12
+
13
+ ### React
14
+
15
+ So long as you have a valid React `<SVG>` node, you can send it as the `customIcon` prop and the kit will take care of the rest.
12
16
 
13
17
  ### Rails
14
18
 
15
- Sending the absolute path to the `icon` prop results in an `<SVG>` tag within the working view.
19
+ Some Rails applications use only webpack(er) which means using `image_url` will be successful over `image_path` in most cases especially development where Webpack Dev Server is serving assets over HTTP. Rails applications still using Asset Pipeline may use `image_path` or `image_url`. Of course, YMMV depending on any custom configurations in your Rails application.
@@ -1,9 +1,7 @@
1
- <% if object.is_svg? %>
2
- <%= object.render_svg %>
3
- <% elsif object.valid_emoji? %>
4
- <span class="pb_icon_kit_emoji">
5
- <%= object.icon.html_safe %>
6
- </span>
1
+ <% if object.custom_icon %>
2
+ <%= object.render_svg(object.custom_icon) %>
3
+ <% elsif object.valid_emoji(object.icon) %>
4
+ <span class="pb_icon_kit_emoji"><%= object.icon.html_safe %></span>
7
5
  <% else %>
8
6
  <%= content_tag(:i, nil,
9
7
  id: object.id,
@@ -38,7 +38,7 @@ module Playbook
38
38
  prop :spin, type: Playbook::Props::Boolean,
39
39
  default: false
40
40
 
41
- def valid_emoji?
41
+ def valid_emoji(icon)
42
42
  emoji_regex = /\p{Emoji}/
43
43
  emoji_regex.match?(icon)
44
44
  end
@@ -79,33 +79,19 @@ module Playbook
79
79
  )
80
80
  end
81
81
 
82
- def asset_path
83
- return unless Rails.application.config.respond_to?(:icon_path)
84
- return unless Dir.entries(Rails.application.config.icon_path).include? "#{icon}.svg"
85
-
86
- Rails.root.join(Rails.application.config.icon_path, "#{icon}.svg")
87
- end
88
-
89
- def render_svg
90
- doc = Nokogiri::XML(URI.open(asset_path || icon || custom_icon)) # rubocop:disable Security/Open
91
- svg = doc.at_css "svg"
92
- svg["class"] = "pb_custom_icon " + object.custom_icon_classname
93
- svg["height"] = "auto"
94
- svg["width"] = "auto"
95
- doc.at_css("path")["fill"] = "currentColor"
96
- raw doc
97
- end
98
-
99
- def is_svg?
100
- (icon || custom_icon.to_s).include?(".svg") || asset_path.present?
82
+ def render_svg(path)
83
+ if File.extname(path) == ".svg"
84
+ doc = Nokogiri::XML(URI.open(path)) # rubocop:disable Security/Open
85
+ svg = doc.at_css "svg"
86
+ svg["class"] = "pb_custom_icon " + object.custom_icon_classname
87
+ raw doc
88
+ else
89
+ raise("Custom icon must be an svg. Please check your path and file type.")
90
+ end
101
91
  end
102
92
 
103
93
  private
104
94
 
105
- def svg_size
106
- size.nil? ? "1x" : size
107
- end
108
-
109
95
  def border_class
110
96
  border ? "fa-border" : nil
111
97
  end
@@ -5,10 +5,11 @@
5
5
  @mixin pb_title(
6
6
  $fontSize: $heading_1,
7
7
  $fontWeight: $lighter,
8
- $lineHeight: $lh_tighter
8
+ $lineHeight: $lh_tighter,
9
+ $letterSpacing: $lspace_tight
9
10
  ){
10
11
  font-size: $fontSize;
11
- letter-spacing: $lspace_tight;
12
+ letter-spacing: $letterSpacing;
12
13
  font-weight: $fontWeight;
13
14
  color: $text_lt_default;
14
15
  margin: 0;
@@ -29,8 +30,7 @@
29
30
  }
30
31
 
31
32
  @mixin pb_title_4 {
32
- @include pb_title($heading_4, $bolder);
33
- letter-spacing: -0.03em;
33
+ @include pb_title($heading_4, $bolder, $letterSpacing: $lspace_normal);
34
34
  }
35
35
 
36
36
  @mixin pb_title_dark {
@@ -1,11 +1,11 @@
1
- $font_family_base: "Proxima Nova", "Helvetica Neue", Helvetica, Arial, sans_serif !default;
1
+ $font_family_base: "Power Centra", "Helvetica Neue", Helvetica, Arial, sans_serif !default;
2
2
 
3
3
  /* CLEAN UP AND REMOVE */
4
4
  $font_jumbo: 36px !default;
5
5
  $font_largest: 32px !default;
6
- $font_larger: 28px !default;
6
+ $font_larger: 27px !default;
7
7
  $font_large: 20px !default;
8
- $font_base: 16px !default;
8
+ $font_base: 15.5px !default;
9
9
  $font_default: $font_base !default;
10
10
  $font_normal: $font_base !default;
11
11
  $font_medium: $font_base !default;
@@ -26,8 +26,8 @@ $text_smaller: $font_smaller !default;
26
26
  $text_smallest: $font_smallest !default;
27
27
 
28
28
  /* Headings */
29
- $heading_1: 46px !default;
30
- $heading_2: 34px !default;
29
+ $heading_1: 44px !default;
30
+ $heading_2: 32px !default;
31
31
  $heading_3: $font_larger !default;
32
32
  $heading_4: $font_base !default;
33
33
 
@@ -35,19 +35,19 @@ $heading_4: $font_base !default;
35
35
  $lspace_tightest: -.1em !default;
36
36
  $lspace_tighter: -.07em !default;
37
37
  $lspace_tight: -.01em !default;
38
- $lspace_normal: 0 !default;
38
+ $lspace_normal: .003em !default;
39
39
  $lspace_loose: .03em !default;
40
40
  $lspace_looser: .07em !default;
41
41
  $lspace_loosest: .1em !default;
42
42
  $lspace_super_loosest: .2em !default;
43
43
 
44
44
  /* Standard Font Weights */
45
- $bold: 600 !default;
45
+ $bold: 700 !default;
46
46
  $regular: 400 !default;
47
47
 
48
48
  /* Non_Standard Font Weights */
49
- $extrabold: 900 !default;
50
- $boldest: 800 !default;
49
+ $extrabold: 700 !default;
50
+ $boldest: 700 !default;
51
51
  $bolder: 700 !default;
52
52
  $light: 300 !default;
53
- $lighter: 100 !default;
53
+ $lighter: 300 !default;