playbook_ui 10.22.1 → 10.23.0.pre.alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d716c8b2fb0fb3cb78211c502bf2049420b05f536fdcc4ad183bce41703d364
4
- data.tar.gz: dcb16d5fc153dc5eba40f0ae8b32299e782a4f3ca929540179a6d08002f15572
3
+ metadata.gz: 1064b4903003c9465a6a1b5684e3ac6d8c0f2c38ce29cfcbc7fd9b7d31d806bd
4
+ data.tar.gz: 647ec3b406545ce663b720a6fcd58afb24b7b6e46157e25f39e9d853df03c10e
5
5
  SHA512:
6
- metadata.gz: 523973d2fa615911426199d7d49d22748926f40e2f704e0fbf6958d632cd7301dade5a6971659fc41fbc7844b98bcff8f80d3efe16554a60fe782d00dfa5dedc
7
- data.tar.gz: f0a6509496789efbbfa0884d08c87fe7d902fe4d09feb07d7f918c7e2d034ce8213d9f01fd48b8132bdcfc584192c7357c6269604912d70356b80b45c1e20fff
6
+ metadata.gz: 1bf4ce670bc7af1955416bca763c2bc29357e0121b2310a8008835451473832a80a888edb80dcc357785ed5cb359797b2bb465985db2982bdfce04f869601362
7
+ data.tar.gz: cccee1ed2ebd68d8249b948df123de1145960acfb2dd5ee34d5388339c24f9f97219cb31499e5e3a07c903dac7398b2b507b10badfefc0968447915af8796232
@@ -13,9 +13,9 @@ $pb_button_sizes: (
13
13
  &[class*=size_#{$name}] {
14
14
  font-size: $size;
15
15
  padding: calc(#{$size} / 2) calc(#{$size} * 2.42) !important;
16
- }
17
- @if $name == "sm" {
18
- min-height: 0;
16
+ @if $name == "sm" {
17
+ min-height: 0;
18
+ }
19
19
  }
20
20
  }
21
21
 
@@ -41,6 +41,7 @@
41
41
  border-bottom-right-radius: 0;
42
42
  border-top-right-radius: 0;
43
43
  min-height: 45px;
44
+ margin-bottom: 16px;
44
45
  }
45
46
 
46
47
  & > [class^=pb_button_kit]:not(:first-child) {
@@ -48,6 +49,7 @@
48
49
  border-top-left-radius: 0;
49
50
  border-left-width: 0;
50
51
  min-height: 45px;
52
+ margin-bottom: 16px;
51
53
  }
52
54
 
53
55
  & > [class^=pb_date_picker_kit]:not(:last-child) {
@@ -73,7 +73,7 @@ module Playbook
73
73
 
74
74
  def render_svg(path)
75
75
  if File.extname(path) == ".svg"
76
- doc = Nokogiri::XML(open(path)) # rubocop:disable Security/Open
76
+ doc = Nokogiri::XML(URI.open(path)) # rubocop:disable Security/Open
77
77
  svg = doc.at_css "svg"
78
78
  svg["class"] = "pb_custom_icon " + object.custom_icon_classname
79
79
  raw doc
@@ -2,7 +2,7 @@ import React from 'react'
2
2
 
3
3
  import Image from '../_image'
4
4
 
5
- const DefaultImage = (props) => {
5
+ const DefaultImage = (props: any) => {
6
6
  return (
7
7
  <>
8
8
  <br />
@@ -1,4 +1,4 @@
1
- export { default as DefaultImage } from './_default_image.jsx'
2
- export { default as RoundedImage } from './_rounded_image.jsx'
3
- export { default as CustomErrorImage } from './_custom_error_image.jsx'
4
- export { default as TransitionImage } from './_transition_image.jsx'
1
+ export { default as DefaultImage } from './_default_image'
2
+ export { default as RoundedImage } from './_rounded_image'
3
+ export { default as CustomErrorImage } from './_custom_error_image'
4
+ export { default as TransitionImage } from './_transition_image'
@@ -1,12 +1,12 @@
1
1
  /* @flow */
2
2
  /* eslint-disable react-hooks/rules-of-hooks */
3
3
 
4
- import React, { useEffect, useRef } from 'react'
4
+ import React, { useEffect, useState } from 'react'
5
5
  import classnames from 'classnames'
6
6
  import inlineFocus from './inlineFocus'
7
7
  import useFocus from './useFocus'
8
8
  import { globalProps } from '../utilities/globalProps'
9
- import { buildAriaProps, buildDataProps } from '../utilities/props'
9
+ import { buildAriaProps, buildDataProps, noop } from '../utilities/props'
10
10
 
11
11
  try {
12
12
  const Trix = require('trix')
@@ -16,6 +16,8 @@ try {
16
16
  }
17
17
  } catch (_e) { /* do nothing */ }
18
18
 
19
+ import { TrixEditor } from "react-trix"
20
+
19
21
  type RichTextEditorProps = {
20
22
  aria?: object,
21
23
  toolbarBottom?: Boolean,
@@ -25,7 +27,7 @@ type RichTextEditorProps = {
25
27
  id?: string,
26
28
  inline?: boolean,
27
29
  name?: string,
28
- onChange: (string) => void,
30
+ onChange: (html: string, text: string) => void,
29
31
  placeholder?: string,
30
32
  simple?: boolean,
31
33
  sticky?: boolean,
@@ -40,133 +42,116 @@ const RichTextEditor = (props: RichTextEditorProps) => {
40
42
  className,
41
43
  data = {},
42
44
  focus = false,
43
- id,
44
45
  inline = false,
45
46
  name,
46
- onChange,
47
+ onChange = noop,
47
48
  placeholder,
48
49
  simple = false,
49
50
  sticky = false,
50
51
  template = '',
51
52
  value = '',
52
53
  } = props
53
- const trixRef = useRef()
54
- const ariaProps = buildAriaProps(aria)
55
- const dataProps = buildDataProps(data)
56
54
 
57
- useEffect(() => {
58
- trixRef.current.addEventListener('trix-initialize', (event) => {
59
- const element = event.target
55
+ const ariaProps = buildAriaProps(aria),
56
+ dataProps = buildDataProps(data),
57
+ [editor, setEditor] = useState()
60
58
 
61
- const { toolbarElement, editor } = element
59
+ const handleOnEditorReady = (editorInstance) => setEditor(editorInstance),
60
+ element = editor?.element
62
61
 
63
- const blockCodeButton = toolbarElement.querySelector(
64
- '[data-trix-attribute=code]'
65
- )
66
- const inlineCodeButton = blockCodeButton.cloneNode(true)
62
+ // DOM manipulation must wait for editor to be ready
63
+ if (editor) {
64
+ const toolbarElement = element.parentElement.querySelector('trix-toolbar'),
65
+ blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]')
67
66
 
68
- inlineCodeButton.hidden = true
69
- inlineCodeButton.dataset.trixAttribute = 'inlineCode'
70
- blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
67
+ let inlineCodeButton = toolbarElement.querySelector('[data-trix-attribute=inlineCode]')
68
+ if (!inlineCodeButton) inlineCodeButton = blockCodeButton.cloneNode(true)
71
69
 
72
- const getCodeFormattingType = () => {
73
- if (editor.attributeIsActive('code')) return 'block'
74
- if (editor.attributeIsActive('inlineCode')) return 'inline'
70
+ // set button attributes
71
+ inlineCodeButton.dataset.trixAttribute = 'inlineCode'
72
+ blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
75
73
 
76
- const range = editor.getSelectedRange()
77
- if (range[0] == range[1]) return 'block'
74
+ if (toolbarBottom) editor.element.after(toolbarElement)
78
75
 
79
- const text = editor.getSelectedDocument().toString().trim()
80
- return /\n/.test(text) ? 'block' : 'inline'
81
- }
76
+ const getCodeFormattingType = (): string => {
77
+ if (editor.attributeIsActive('code')) return 'block'
78
+ if (editor.attributeIsActive('inlineCode')) return 'inline'
82
79
 
83
- element.addEventListener('trix-selection-change', () => {
84
- const type = getCodeFormattingType()
85
- blockCodeButton.hidden = type == 'inline'
86
- inlineCodeButton.hidden = type == 'block'
87
- })
80
+ const range = editor.getSelectedRange()
81
+ if (range[0] == range[1]) return 'block'
88
82
 
89
- if (toolbarBottom) editor.element.after(toolbarElement)
90
- })
91
-
92
- trixRef.current.addEventListener('trix-change', (event) => {
93
- onChange && onChange(event.target.innerHTML)
94
- })
95
- }, [trixRef])
96
-
97
- useEffect(() => {
98
- const editor = trixRef.current.editorController.editor
99
- if (template) {
100
- editor.loadHTML('')
101
- editor.setSelectedRange([0, 0])
102
- editor.insertHTML(template)
83
+ const text = editor.getSelectedDocument().toString().trim()
84
+ return /\n/.test(text) ? 'block' : 'inline'
103
85
  }
104
- }, [template])
105
-
106
- focus
107
- ? (document.addEventListener('trix-focus', useFocus),
108
- document.addEventListener('trix-blur', useFocus),
109
- useFocus())
110
- : null
111
-
112
- document.addEventListener('trix-focus', inlineFocus)
113
- document.addEventListener('trix-blur', inlineFocus)
114
86
 
115
- const handleAnchorElementClick = (clickedElement) => {
116
- const trixEditorContainer = clickedElement.closest('.pb_rich_text_editor_kit')
117
- if (!trixEditorContainer) return
118
-
119
- const anchorElement = clickedElement.closest('a')
120
- if (!anchorElement) return
87
+ // DOM event listeners
88
+ element.addEventListener('trix-selection-change', () => {
89
+ const type = getCodeFormattingType()
90
+ blockCodeButton.hidden = type == 'inline'
91
+ inlineCodeButton.hidden = type == 'block'
92
+ })
121
93
 
122
- if (anchorElement.hasAttribute('href')) window.open(anchorElement.href)
123
- }
94
+ focus
95
+ ? (document.addEventListener('trix-focus', useFocus),
96
+ document.addEventListener('trix-blur', useFocus),
97
+ useFocus())
98
+ : null
124
99
 
125
- const handleClick = (event) => {
126
- handleAnchorElementClick(event.target)
100
+ document.addEventListener('trix-focus', inlineFocus)
101
+ document.addEventListener('trix-blur', inlineFocus)
127
102
  }
128
103
 
129
104
  useEffect(() => {
130
- trixRef.current.addEventListener('click', handleClick)
131
- }, [])
105
+ if (!editor || !template) return
106
+ editor.loadHTML('')
107
+ editor.setSelectedRange([0, 0])
108
+ editor.insertHTML(template)
109
+ }, [editor, template])
132
110
 
133
111
  useEffect(() => {
134
- trixRef.current.editor.loadHTML(value)
135
- }, [value])
112
+ if (!element) return
113
+ element.addEventListener('click', ({target}) => {
114
+ const trixEditorContainer = target.closest('.pb_rich_text_editor_kit')
115
+ if (!trixEditorContainer) return
136
116
 
137
- const RichTextEditorClass = 'pb_rich_text_editor_kit'
138
- const SimpleClass = simple ? 'simple' : ''
139
- const FocusClass = focus ? 'focus-editor-targets' : ''
140
- const StickyClass = sticky ? 'sticky' : ''
141
- const InlineClass = inline ? 'inline' : ''
142
- const ToolbarBottomClass = toolbarBottom ? 'toolbar-bottom' : ''
143
- const css = classnames(globalProps(props), className)
117
+ const anchorElement = target.closest('a')
118
+ if (!anchorElement) return
119
+
120
+ if (anchorElement.hasAttribute('href')) window.open(anchorElement.href)
121
+ })
122
+ }, [element])
123
+
124
+ const richTextEditorClass = 'pb_rich_text_editor_kit',
125
+ simpleClass = simple ? 'simple' : '',
126
+ focusClass = focus ? 'focus-editor-targets' : '',
127
+ stickyClass = sticky ? 'sticky' : '',
128
+ inlineClass = inline ? 'inline' : '',
129
+ toolbarBottomClass = toolbarBottom ? 'toolbar-bottom' : ''
130
+
131
+ let css = classnames(globalProps(props), className)
132
+ css = classnames(
133
+ richTextEditorClass,
134
+ simpleClass,
135
+ focusClass,
136
+ stickyClass,
137
+ inlineClass,
138
+ toolbarBottomClass,
139
+ css
140
+ )
144
141
 
145
142
  return (
146
143
  <div
147
144
  {...ariaProps}
148
145
  {...dataProps}
149
- className={classnames(
150
- RichTextEditorClass,
151
- SimpleClass,
152
- FocusClass,
153
- StickyClass,
154
- InlineClass,
155
- ToolbarBottomClass,
156
- css
157
- )}
146
+ className={css}
158
147
  >
159
- <input
160
- id={id}
161
- name={name}
162
- type="hidden"
163
- value={value}
164
- />
165
- <trix-editor
166
- input={id}
167
- name={name}
148
+ <TrixEditor
149
+ className=""
150
+ fileParamName={name}
151
+ onChange={onChange}
152
+ onEditorReady={handleOnEditorReady}
168
153
  placeholder={placeholder}
169
- ref={trixRef}
154
+ value={value}
170
155
  />
171
156
  </div>
172
157
  )
@@ -1 +1 @@
1
- <%= pb_rails("rich_text_editor", props: {id: "default"}) %>
1
+ <%= pb_rails("rich_text_editor", props: {id: "default", value: "Add your text here. You can format your text, add links, quotes, and bullets."}) %>
@@ -1,12 +1,19 @@
1
- import React from 'react'
1
+ import React, { useState } from 'react'
2
2
  import { RichTextEditor } from '../../'
3
3
 
4
- const RichTextEditorDefault = (props) => (
5
- <div>
6
- <RichTextEditor
7
- {...props}
8
- />
9
- </div>
10
- )
4
+ const RichTextEditorDefault = (props) => {
5
+ const [value, setValue] = useState('Add your text here. You can format your text, add links, quotes, and bullets.'),
6
+ handleOnChange = (html) => setValue(html)
7
+
8
+ return (
9
+ <div>
10
+ <RichTextEditor
11
+ onChange={handleOnChange}
12
+ value={value}
13
+ {...props}
14
+ />
15
+ </div>
16
+ )
17
+ }
11
18
 
12
19
  export default RichTextEditorDefault
@@ -59,7 +59,59 @@ type BorderRadius = {
59
59
  borderRadius?: "none" | "xs" | "sm" | "md" | "lg" | "xl" | "rounded",
60
60
  }
61
61
 
62
- export type GlobalProps = BorderRadius & Cursor & Dark & Display & LineHeight & Margin & MaxWidth & NumberSpacing & Padding & Shadow & ZIndex
62
+ type Flex = {
63
+ flex?: "none" | "initial" | "auto" | 1
64
+ }
65
+
66
+ type FlexDirection = {
67
+ flexDirection?: "row" | "column" | "rowReverse" | "columnReverse"
68
+ }
69
+
70
+ type FlexGrow = {
71
+ flexGrow?: 0 | 1
72
+ }
73
+
74
+ type FlexShrink = {
75
+ flexShrink?: 0 | 1
76
+ }
77
+
78
+ type FlexWrap = {
79
+ flexWrap?: "wrap" | "nowrap" | "wrapReverse"
80
+ }
81
+
82
+ type Alignment = "start" | "end" | "center"
83
+
84
+ type Space = "spaceBetween" | "spaceAround" | "spaceEvenly"
85
+
86
+ type JustifyContent = {
87
+ justifyContent?: Alignment & Space
88
+ }
89
+
90
+ type JustifySelf = {
91
+ justifySelf?: Alignment & ("auto" | "stretch")
92
+ }
93
+
94
+ type AlignContent = {
95
+ alignContent?: Alignment & Space
96
+ }
97
+
98
+ type AlignItems = {
99
+ alignItems?: Alignment & ("flexStart" | "flexEnd" | "stretch" | "baseline")
100
+ }
101
+
102
+ type AlignSelf = {
103
+ alignSelf?: Alignment & ("auto" | "stretch" | "baseline")
104
+ }
105
+
106
+ type Order = {
107
+ order?: "none" | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
108
+ }
109
+
110
+ export type GlobalProps = AlignContent & AlignItems & AlignSelf &
111
+ BorderRadius & Cursor & Dark & Display & Flex & FlexDirection &
112
+ FlexGrow & FlexShrink & FlexWrap & JustifyContent & JustifySelf &
113
+ LineHeight & Margin & MaxWidth & NumberSpacing & Order & Padding &
114
+ Shadow & ZIndex
63
115
 
64
116
  // Prop categories
65
117
  const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} = {
@@ -135,15 +187,81 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
135
187
  let css = ''
136
188
  css += cursor ? `cursor_${cursor} ` : ''
137
189
  return css
190
+ },
191
+ flexDirectionProps: ({ flexDirection }: FlexDirection) => {
192
+ let css = ''
193
+ css += flexDirection == 'columnReverse' ? 'flex_direction_column_reverse' :
194
+ flexDirection == 'rowReverse' ? 'flex_direction_row_reverse' :
195
+ flexDirection ? `flex_direction_${flexDirection} ` : ''
196
+ return css
197
+ },
198
+ flexWrapProps: ({ flexWrap }: FlexWrap) => {
199
+ let css = ''
200
+ css += flexWrap == 'wrapReverse' ? 'flex_wrap_reverse' :
201
+ flexWrap == 'nowrap' ? 'flex_nowrap' :
202
+ flexWrap ? `flex_wrap_${flexWrap} ` : ''
203
+ return css
204
+ },
205
+ justifyContentProps: ({ justifyContent }: JustifyContent) => {
206
+ let css = ''
207
+ css += justifyContent == 'spaceBetween' ? 'justify_content_space_between' :
208
+ justifyContent == 'spaceEvenly' ? 'justify_content_space_evenly' :
209
+ justifyContent == 'spaceAround' ? 'justify_content_space_around' :
210
+ justifyContent ? `justify_content_${justifyContent}` : ''
211
+ return css
212
+ },
213
+ justifySelfProps: ({ justifySelf }: JustifySelf) => {
214
+ let css = ''
215
+ css += justifySelf ? `justify_self_${justifySelf}` : ''
216
+ return css
217
+ },
218
+ alignItemsProps: ({ alignItems }: AlignItems) => {
219
+ let css = ''
220
+ css += alignItems == 'flexStart' ? 'align_items_flex_start' :
221
+ alignItems == 'flexEnd' ? 'align_items_flex_end' :
222
+ alignItems ? `align_items_${alignItems}` : ''
223
+ return css
224
+ },
225
+ alignContentProps: ({ alignContent }: AlignContent) => {
226
+ let css = ''
227
+ css += alignContent == 'spaceBetween' ? 'align_content_space_between' :
228
+ alignContent == 'spaceEvenly' ? 'align_content_space_evenly' :
229
+ alignContent == 'spaceAround' ? 'align_content_space_around' :
230
+ alignContent ? `align_content_${alignContent}` : ''
231
+ return css
232
+ },
233
+ alignSelfProps: ({ alignSelf }: AlignSelf) => {
234
+ let css = ''
235
+ css += alignSelf ? `align_self_${alignSelf}` : ''
236
+ return css
237
+ },
238
+ flexProps: ({ flex }: Flex) => {
239
+ let css = ''
240
+ css += flex ? `flex_${flex}` : ''
241
+ return css
242
+ },
243
+ flexGrowProps: ({ flexGrow }: FlexGrow) => {
244
+ let css = ''
245
+ css += flexGrow ? `flex_grow_${flexGrow}` : ''
246
+ return css
247
+ },
248
+ flexShrinkProps: ({ flexShrink }: FlexShrink) => {
249
+ let css = ''
250
+ css += flexShrink ? `flex_shrink_${flexShrink}` : ''
251
+ return css
252
+ },
253
+ orderProps: ({ order }: Order) => {
254
+ let css = ''
255
+ css += order ? `order_${order}` : ''
256
+ return css
138
257
  }
139
258
  }
140
259
 
141
- // All Exported as a single function
142
260
  export const globalProps = (props: GlobalProps, defaultProps: {[key: string]: string} | {} = {}): string => {
143
261
  const allProps = { ...props, ...defaultProps }
144
262
  return Object.keys(PROP_CATEGORIES).map((key) => {
145
263
  return PROP_CATEGORIES[key](allProps)
146
- }).join("")
264
+ }).filter((value) => value?.length > 0).join(" ")
147
265
  }
148
266
 
149
267
  export const deprecatedProps = (kit: string, props: string[] = []): void => {
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playbook
4
- PREVIOUS_VERSION = "10.22.0"
5
- VERSION = "10.22.1"
4
+ PREVIOUS_VERSION = "10.21.0"
5
+ VERSION = "10.23.0.pre.alpha1"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.22.1
4
+ version: 10.23.0.pre.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -1092,7 +1092,7 @@ files:
1092
1092
  - app/pb_kits/playbook/pb_image/docs/_custom_error_image.html.erb
1093
1093
  - app/pb_kits/playbook/pb_image/docs/_custom_error_image.jsx
1094
1094
  - app/pb_kits/playbook/pb_image/docs/_default_image.html.erb
1095
- - app/pb_kits/playbook/pb_image/docs/_default_image.jsx
1095
+ - app/pb_kits/playbook/pb_image/docs/_default_image.tsx
1096
1096
  - app/pb_kits/playbook/pb_image/docs/_description.md
1097
1097
  - app/pb_kits/playbook/pb_image/docs/_rounded_image.html.erb
1098
1098
  - app/pb_kits/playbook/pb_image/docs/_rounded_image.jsx
@@ -2086,7 +2086,6 @@ files:
2086
2086
  - app/pb_kits/playbook/utilities/_positioning.scss
2087
2087
  - app/pb_kits/playbook/utilities/_shadow.scss
2088
2088
  - app/pb_kits/playbook/utilities/_spacing.scss
2089
- - app/pb_kits/playbook/utilities/globalProps.js
2090
2089
  - app/pb_kits/playbook/utilities/globalProps.ts
2091
2090
  - app/pb_kits/playbook/utilities/props.ts
2092
2091
  - app/pb_kits/playbook/utilities/test-utils.js
@@ -2164,9 +2163,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
2164
2163
  version: '0'
2165
2164
  required_rubygems_version: !ruby/object:Gem::Requirement
2166
2165
  requirements:
2167
- - - ">="
2166
+ - - ">"
2168
2167
  - !ruby/object:Gem::Version
2169
- version: '0'
2168
+ version: 1.3.1
2170
2169
  requirements: []
2171
2170
  rubygems_version: 3.1.6
2172
2171
  signing_key:
@@ -1,175 +0,0 @@
1
- // Prop categories
2
- const spacingProps = ({
3
- marginRight,
4
- marginLeft,
5
- marginTop,
6
- marginBottom,
7
- marginX,
8
- marginY,
9
- margin,
10
- paddingRight,
11
- paddingLeft,
12
- paddingTop,
13
- paddingBottom,
14
- paddingX,
15
- paddingY,
16
- padding,
17
- }) => {
18
- let css = ''
19
- css += marginRight ? `mr_${marginRight} ` : ''
20
- css += marginLeft ? `ml_${marginLeft} ` : ''
21
- css += marginTop ? `mt_${marginTop} ` : ''
22
- css += marginBottom ? `mb_${marginBottom} ` : ''
23
- css += marginX ? `mx_${marginX} ` : ''
24
- css += marginY ? `my_${marginY} ` : ''
25
- css += margin ? `m_${margin} ` : ''
26
- css += paddingRight ? `pr_${paddingRight} ` : ''
27
- css += paddingLeft ? `pl_${paddingLeft} ` : ''
28
- css += paddingTop ? `pt_${paddingTop} ` : ''
29
- css += paddingBottom ? `pb_${paddingBottom} ` : ''
30
- css += paddingX ? `px_${paddingX} ` : ''
31
- css += paddingY ? `py_${paddingY} ` : ''
32
- css += padding ? `p_${padding} ` : ''
33
- return css
34
- }
35
-
36
- const darkProps = ({ dark }) => {
37
- let css = ''
38
- css += dark ? 'dark' : ''
39
- return css
40
- }
41
-
42
- const numberSpacingProps = ({ numberSpacing }) => {
43
- let css = ''
44
- css += numberSpacing ? `ns_${numberSpacing} ` : ''
45
- return css
46
- }
47
-
48
- const maxWidthProps = ({ maxWidth }) => {
49
- let css = ''
50
- css += maxWidth ? `max_width_${maxWidth} ` : ''
51
- return css
52
- }
53
-
54
- const zIndexProps = ({ zIndex }) => {
55
- let css = ''
56
- css += zIndex ? `z_index_${zIndex} ` : ''
57
- return css
58
- }
59
-
60
- const shadowProps = ({ shadow }) => {
61
- let css = ''
62
- css += shadow ? `shadow_${shadow} ` : ''
63
- return css
64
- }
65
-
66
- const lineHeightProps = ({ lineHeight }) => {
67
- let css = ''
68
- css += lineHeight ? `line_height_${lineHeight} ` : ''
69
- return css
70
- }
71
-
72
- const displayProps = ({ display }) => {
73
- let css = ''
74
- css += display ? `display_${display} ` : ''
75
- return css
76
- }
77
-
78
- const cursorProps = ({ cursor }) => {
79
- let css = ''
80
- css += cursor ? `cursor_${cursor} ` : ''
81
- return css
82
- }
83
-
84
- const flexDirectionProps = ({ flexDirection }) => {
85
- let css = ''
86
- css += flexDirection == 'columnReverse' ? 'flex_direction_column_reverse' :
87
- flexDirection == 'rowReverse' ? 'flex_direction_row_reverse' :
88
- flexDirection ? `flex_direction_${flexDirection} ` : ''
89
- return css
90
- }
91
-
92
- const flexWrapProps = ({ flexWrap }) => {
93
- let css = ''
94
- css += flexWrap == 'wrapReverse' ? 'flex_wrap_reverse' :
95
- flexWrap == 'noWrap' ? 'flex_nowrap' :
96
- flexWrap ? `flex_wrap_${flexWrap} ` : ''
97
- return css
98
- }
99
-
100
- const justifyContentProps = ({ justifyContent }) => {
101
- let css = ''
102
- css += justifyContent == 'spaceBetween' ? 'justify_content_space_between' :
103
- justifyContent == 'spaceEvenly' ? 'justify_content_space_evenly' :
104
- justifyContent == 'spaceAround' ? 'justify_content_space_around' :
105
- justifyContent ? `justify_content_${justifyContent}` : ''
106
- return css
107
- }
108
-
109
- const justifySelfProps = ({ justifySelf }) => {
110
- let css = ''
111
- css += justifySelf ? `justify_self_${justifySelf}` : ''
112
- return css
113
- }
114
-
115
- const alignItemsProps = ({ alignItems }) => {
116
- let css = ''
117
- css += alignItems == 'flexStart' ? 'align_items_flex_start' :
118
- alignItems == 'flexEnd' ? 'align_items_flex_end' :
119
- alignItems ? `align_items_${alignItems}` : ''
120
- return css
121
- }
122
-
123
- const alignContentProps = ({ alignContent }) => {
124
- let css = ''
125
- css += alignContent == 'spaceBetween' ? 'align_content_space_between' :
126
- alignContent == 'spaceEvenly' ? 'align_content_space_evenly' :
127
- alignContent == 'spaceAround' ? 'align_content_space_around' :
128
- alignContent ? `align_content_${alignContent}` : ''
129
- return css
130
- }
131
-
132
- const alignSelfProps = ({ alignSelf }) => {
133
- let css = ''
134
- css += alignSelf ? `align_self_${alignSelf}` : ''
135
- return css
136
- }
137
-
138
- const flexProps = ({ flex }) => {
139
- let css = ''
140
- css += flex ? `flex_${flex}` : ''
141
- return css
142
- }
143
-
144
- const flexGrowProps = ({ flexGrow }) => {
145
- let css = ''
146
- css += flexGrow ? `flex_grow_${flexGrow}` : ''
147
- return css
148
- }
149
-
150
- const flexShrinkProps = ({ flexShrink }) => {
151
- let css = ''
152
- css += flexShrink ? `flex_shrink_${flexShrink}` : ''
153
- return css
154
- }
155
-
156
- const orderProps = ({ order }) => {
157
- let css = ''
158
- css += order ? `order_${order}` : ''
159
- return css
160
- }
161
-
162
- // All Exported as a single function
163
- export const globalProps = (props, defaultProps = {}) => {
164
- const allProps = { ...props, ...defaultProps }
165
- return spacingProps(allProps) + darkProps(allProps) + maxWidthProps(allProps) + zIndexProps(allProps) + numberSpacingProps(allProps) + shadowProps(allProps) + lineHeightProps(allProps) + cursorProps(allProps) + displayProps(allProps) + flexDirectionProps(allProps) + flexWrapProps(allProps) + justifyContentProps(allProps) + justifySelfProps(allProps) + alignItemsProps(allProps) + alignContentProps(allProps) + alignSelfProps(allProps) + flexProps(allProps) + flexGrowProps(allProps) + flexShrinkProps(allProps) + orderProps(allProps)
166
- }
167
-
168
- export const deprecatedProps = (kit, props = []) => {
169
- if (process.env.NODE_ENV === 'development') {
170
- /* eslint no-console: ["error", { allow: ["warn", "error"] }] */
171
- props.forEach((prop) => {
172
- console.warn(`${kit} Kit: The prop '${prop}' is deprecated and will be removed in a future release!`)
173
- })
174
- }
175
- }