@slimr/styled 2.1.15 → 2.1.18

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.
package/cjs/styled.ts CHANGED
@@ -10,187 +10,209 @@ type TSP = T2SProps
10
10
  /** Shorthand type */
11
11
  type HTP = JSX.IntrinsicElements
12
12
 
13
+ /**
14
+ * Create React components with styles using familiar syntax. See
15
+ * [npm](https://www.npmjs.com/package/@slimr/styled) for more info.
16
+ *
17
+ * @param component
18
+ * a functional component to be styled; must accept a className prop
19
+ *
20
+ * @returns
21
+ * a function that accepts a template string of css returns a decorated React component
22
+ *
23
+ * @example
24
+ * const Button = styled('button')`
25
+ * c: red; // color shorthand
26
+ * w: [100%, null, 300px]; // responsive width = 100% on mobile, 300px on desktop
27
+ * `
28
+ * const Button2 = styled.button`
29
+ * c: blue;
30
+ * `
31
+ * const Button3 = styled(Button)`
32
+ * bg: red;
33
+ * `
34
+ */
13
35
  export const styled = Object.assign(s, {
14
- /** creates a 'a' component with css applied */
36
+ /** creates a 'a' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
15
37
  a: (...p: TSP) => s('a' as unk as FC<HTP['a']>)(...p),
16
- /** creates a 'abbr' component with css applied */
38
+ /** creates a 'abbr' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
17
39
  abbr: (...p: TSP) => s('abbr' as unk as FC<HTP['abbr']>)(...p),
18
- /** creates a 'address' component with css applied */
40
+ /** creates a 'address' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
19
41
  address: (...p: TSP) => s('address' as unk as FC<HTP['address']>)(...p),
20
- /** creates a 'area' component with css applied */
42
+ /** creates a 'area' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
21
43
  area: (...p: TSP) => s('area' as unk as FC<HTP['area']>)(...p),
22
- /** creates a 'article' component with css applied */
44
+ /** creates a 'article' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
23
45
  article: (...p: TSP) => s('article' as unk as FC<HTP['article']>)(...p),
24
- /** creates a 'aside' component with css applied */
46
+ /** creates a 'aside' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
25
47
  aside: (...p: TSP) => s('aside' as unk as FC<HTP['aside']>)(...p),
26
- /** creates a 'audio' component with css applied */
48
+ /** creates a 'audio' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
27
49
  audio: (...p: TSP) => s('audio' as unk as FC<HTP['audio']>)(...p),
28
- /** creates a 'b' component with css applied */
50
+ /** creates a 'b' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
29
51
  b: (...p: TSP) => s('b' as unk as FC<HTP['b']>)(...p),
30
- /** creates a 'big' component with css applied; Deprecated so left out */
52
+ /** creates a 'big' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info.; Deprecated so left out */
31
53
  // big: (...p: TSP) => styled('big' as unk as FC<HTP['big']>)(...p),
32
- /** creates a 'blockquote' component with css applied */
54
+ /** creates a 'blockquote' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
33
55
  blockquote: (...p: TSP) => s('blockquote' as unk as FC<HTP['blockquote']>)(...p),
34
- /** creates a 'body' component with css applied; omitted bc doesnt seem useful */
56
+ /** creates a 'body' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info.; omitted bc doesnt seem useful */
35
57
  // body: (...p: TSP) => styled('body' as unk as FC<HTP['body']>)(...p),
36
- /** creates a 'br' component with css applied; omitted bc doesnt seem useful */
58
+ /** creates a 'br' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info.; omitted bc doesnt seem useful */
37
59
  br: (...p: TSP) => s('br' as unk as FC<HTP['br']>)(...p),
38
- /** creates a 'button' component with css applied */
60
+ /** creates a 'button' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
39
61
  button: (...p: TSP) => s('button' as unk as FC<HTP['button']>)(...p),
40
- /** creates a 'caption' component with css applied */
62
+ /** creates a 'caption' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
41
63
  caption: (...p: TSP) => s('caption' as unk as FC<HTP['caption']>)(...p),
42
- /** creates a 'cite' component with css applied */
64
+ /** creates a 'cite' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
43
65
  cite: (...p: TSP) => s('cite' as unk as FC<HTP['cite']>)(...p),
44
- /** creates a 'code' component with css applied */
66
+ /** creates a 'code' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
45
67
  code: (...p: TSP) => s('code' as unk as FC<HTP['code']>)(...p),
46
- /** creates a 'col' component with css applied */
68
+ /** creates a 'col' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
47
69
  col: (...p: TSP) => s('col' as unk as FC<HTP['col']>)(...p),
48
- /** creates a 'colgroup' component with css applied */
70
+ /** creates a 'colgroup' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
49
71
  colgroup: (...p: TSP) => s('colgroup' as unk as FC<HTP['colgroup']>)(...p),
50
- /** creates a 'dd' component with css applied */
72
+ /** creates a 'dd' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
51
73
  dd: (...p: TSP) => s('dd' as unk as FC<HTP['dd']>)(...p),
52
- /** creates a 'del' component with css applied */
74
+ /** creates a 'del' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
53
75
  del: (...p: TSP) => s('del' as unk as FC<HTP['del']>)(...p),
54
- /** creates a 'details' component with css applied */
76
+ /** creates a 'details' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
55
77
  details: (...p: TSP) => s('details' as unk as FC<HTP['details']>)(...p),
56
- /** creates a 'dfn' component with css applied */
78
+ /** creates a 'dfn' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
57
79
  dfn: (...p: TSP) => s('dfn' as unk as FC<HTP['dfn']>)(...p),
58
- /** creates a 'dialog' component with css applied */
80
+ /** creates a 'dialog' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
59
81
  dialog: (...p: TSP) => s('dialog' as unk as FC<HTP['dialog']>)(...p),
60
- /** creates a 'div' component with css applied */
82
+ /** creates a 'div' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
61
83
  div: (...p: TSP) => s('div' as unk as FC<HTP['div']>)(...p),
62
- /** creates a 'dl' component with css applied */
84
+ /** creates a 'dl' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
63
85
  dl: (...p: TSP) => s('dl' as unk as FC<HTP['dl']>)(...p),
64
- /** creates a 'dt' component with css applied */
86
+ /** creates a 'dt' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
65
87
  dt: (...p: TSP) => s('dt' as unk as FC<HTP['dt']>)(...p),
66
- /** creates a 'em' component with css applied */
88
+ /** creates a 'em' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
67
89
  em: (...p: TSP) => s('em' as unk as FC<HTP['em']>)(...p),
68
- /** creates a 'embed' component with css applied */
90
+ /** creates a 'embed' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
69
91
  embed: (...p: TSP) => s('embed' as unk as FC<HTP['embed']>)(...p),
70
- /** creates a 'fieldset' component with css applied */
92
+ /** creates a 'fieldset' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
71
93
  fieldset: (...p: TSP) => s('fieldset' as unk as FC<HTP['fieldset']>)(...p),
72
- /** creates a 'figcaption' component with css applied */
94
+ /** creates a 'figcaption' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
73
95
  figcaption: (...p: TSP) => s('figcaption' as unk as FC<HTP['figcaption']>)(...p),
74
- /** creates a 'figure' component with css applied */
96
+ /** creates a 'figure' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
75
97
  figure: (...p: TSP) => s('figure' as unk as FC<HTP['figure']>)(...p),
76
- /** creates a 'footer' component with css applied */
98
+ /** creates a 'footer' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
77
99
  footer: (...p: TSP) => s('footer' as unk as FC<HTP['footer']>)(...p),
78
- /** creates a 'form' component with css applied */
100
+ /** creates a 'form' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
79
101
  form: (...p: TSP) => s('form' as unk as FC<HTP['form']>)(...p),
80
- /** creates a 'h1' component with css applied */
102
+ /** creates a 'h1' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
81
103
  h1: (...p: TSP) => s('h1' as unk as FC<HTP['h1']>)(...p),
82
- /** creates a 'h2' component with css applied */
104
+ /** creates a 'h2' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
83
105
  h2: (...p: TSP) => s('h2' as unk as FC<HTP['h2']>)(...p),
84
- /** creates a 'h3' component with css applied */
106
+ /** creates a 'h3' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
85
107
  h3: (...p: TSP) => s('h3' as unk as FC<HTP['h3']>)(...p),
86
- /** creates a 'h4' component with css applied */
108
+ /** creates a 'h4' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
87
109
  h4: (...p: TSP) => s('h4' as unk as FC<HTP['h4']>)(...p),
88
- /** creates a 'h5' component with css applied */
110
+ /** creates a 'h5' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
89
111
  h5: (...p: TSP) => s('h5' as unk as FC<HTP['h5']>)(...p),
90
- /** creates a 'h6' component with css applied */
112
+ /** creates a 'h6' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
91
113
  h6: (...p: TSP) => s('h6' as unk as FC<HTP['h6']>)(...p),
92
- /** creates a 'header' component with css applied */
114
+ /** creates a 'header' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
93
115
  header: (...p: TSP) => s('header' as unk as FC<HTP['header']>)(...p),
94
- /** creates a 'hgroup' component with css applied */
116
+ /** creates a 'hgroup' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
95
117
  hgroup: (...p: TSP) => s('hgroup' as unk as FC<HTP['hgroup']>)(...p),
96
- /** creates a 'hr' component with css applied */
118
+ /** creates a 'hr' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
97
119
  hr: (...p: TSP) => s('hr' as unk as FC<HTP['hr']>)(...p),
98
- /** creates a 'i' component with css applied */
120
+ /** creates a 'i' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
99
121
  i: (...p: TSP) => s('i' as unk as FC<HTP['i']>)(...p),
100
- /** creates a 'iframe' component with css applied */
122
+ /** creates a 'iframe' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
101
123
  iframe: (...p: TSP) => s('iframe' as unk as FC<HTP['iframe']>)(...p),
102
- /** creates a 'img' component with css applied */
124
+ /** creates a 'img' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
103
125
  img: (...p: TSP) => s('img' as unk as FC<HTP['img']>)(...p),
104
- /** creates a 'input' component with css applied */
126
+ /** creates a 'input' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
105
127
  input: (...p: TSP) => s('input' as unk as FC<HTP['input']>)(...p),
106
- /** creates a 'ins' component with css applied */
128
+ /** creates a 'ins' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
107
129
  ins: (...p: TSP) => s('ins' as unk as FC<HTP['ins']>)(...p),
108
- /** creates a 'kbd' component with css applied */
130
+ /** creates a 'kbd' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
109
131
  kbd: (...p: TSP) => s('kbd' as unk as FC<HTP['kbd']>)(...p),
110
- /** creates a 'label' component with css applied */
132
+ /** creates a 'label' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
111
133
  label: (...p: TSP) => s('label' as unk as FC<HTP['label']>)(...p),
112
- /** creates a 'legend' component with css applied */
134
+ /** creates a 'legend' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
113
135
  legend: (...p: TSP) => s('legend' as unk as FC<HTP['legend']>)(...p),
114
- /** creates a 'li' component with css applied */
136
+ /** creates a 'li' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
115
137
  li: (...p: TSP) => s('li' as unk as FC<HTP['li']>)(...p),
116
- /** creates a 'main' component with css applied */
138
+ /** creates a 'main' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
117
139
  main: (...p: TSP) => s('main' as unk as FC<HTP['main']>)(...p),
118
- /** creates a 'map' component with css applied */
140
+ /** creates a 'map' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
119
141
  map: (...p: TSP) => s('map' as unk as FC<HTP['map']>)(...p),
120
- /** creates a 'mark' component with css applied */
142
+ /** creates a 'mark' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
121
143
  mark: (...p: TSP) => s('mark' as unk as FC<HTP['mark']>)(...p),
122
- /** creates a 'meter' component with css applied */
144
+ /** creates a 'meter' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
123
145
  meter: (...p: TSP) => s('meter' as unk as FC<HTP['meter']>)(...p),
124
- /** creates a 'nav' component with css applied */
146
+ /** creates a 'nav' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
125
147
  nav: (...p: TSP) => s('nav' as unk as FC<HTP['nav']>)(...p),
126
- /** creates a 'object' component with css applied */
148
+ /** creates a 'object' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
127
149
  object: (...p: TSP) => s('object' as unk as FC<HTP['object']>)(...p),
128
- /** creates a 'ol' component with css applied */
150
+ /** creates a 'ol' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
129
151
  ol: (...p: TSP) => s('ol' as unk as FC<HTP['ol']>)(...p),
130
- /** creates a 'optgroup' component with css applied */
152
+ /** creates a 'optgroup' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
131
153
  optgroup: (...p: TSP) => s('optgroup' as unk as FC<HTP['optgroup']>)(...p),
132
- /** creates a 'option' component with css applied */
154
+ /** creates a 'option' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
133
155
  option: (...p: TSP) => s('option' as unk as FC<HTP['option']>)(...p),
134
- /** creates a 'output' component with css applied */
156
+ /** creates a 'output' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
135
157
  output: (...p: TSP) => s('output' as unk as FC<HTP['output']>)(...p),
136
- /** creates a 'p' component with css applied */
158
+ /** creates a 'p' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
137
159
  p: (...p: TSP) => s('p' as unk as FC<HTP['p']>)(...p),
138
- /** creates a 'picture' component with css applied */
160
+ /** creates a 'picture' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
139
161
  picture: (...p: TSP) => s('picture' as unk as FC<HTP['picture']>)(...p),
140
- /** creates a 'pre' component with css applied */
162
+ /** creates a 'pre' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
141
163
  pre: (...p: TSP) => s('pre' as unk as FC<HTP['pre']>)(...p),
142
- /** creates a 'progress' component with css applied */
164
+ /** creates a 'progress' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
143
165
  progress: (...p: TSP) => s('progress' as unk as FC<HTP['progress']>)(...p),
144
- /** creates a 'q' component with css applied */
166
+ /** creates a 'q' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
145
167
  q: (...p: TSP) => s('q' as unk as FC<HTP['q']>)(...p),
146
- /** creates a 'rp' component with css applied */
168
+ /** creates a 'rp' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
147
169
  rp: (...p: TSP) => s('rp' as unk as FC<HTP['rp']>)(...p),
148
- /** creates a 'rt' component with css applied */
170
+ /** creates a 'rt' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
149
171
  rt: (...p: TSP) => s('rt' as unk as FC<HTP['rt']>)(...p),
150
- /** creates a 'ruby' component with css applied */
172
+ /** creates a 'ruby' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
151
173
  ruby: (...p: TSP) => s('ruby' as unk as FC<HTP['ruby']>)(...p),
152
- /** creates a 's' component with css applied */
174
+ /** creates a 's' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
153
175
  s: (...p: TSP) => s('s' as unk as FC<HTP['s']>)(...p),
154
- /** creates a 'samp' component with css applied */
176
+ /** creates a 'samp' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
155
177
  samp: (...p: TSP) => s('samp' as unk as FC<HTP['samp']>)(...p),
156
- /** creates a 'section' component with css applied */
178
+ /** creates a 'section' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
157
179
  section: (...p: TSP) => s('section' as unk as FC<HTP['section']>)(...p),
158
- /** creates a 'select' component with css applied */
180
+ /** creates a 'select' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
159
181
  select: (...p: TSP) => s('select' as unk as FC<HTP['select']>)(...p),
160
- /** creates a 'small' component with css applied */
182
+ /** creates a 'small' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
161
183
  small: (...p: TSP) => s('small' as unk as FC<HTP['small']>)(...p),
162
- /** creates a 'span' component with css applied */
184
+ /** creates a 'span' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
163
185
  span: (...p: TSP) => s('span' as unk as FC<HTP['span']>)(...p),
164
- /** creates a 'strong' component with css applied */
186
+ /** creates a 'strong' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
165
187
  strong: (...p: TSP) => s('strong' as unk as FC<HTP['strong']>)(...p),
166
- /** creates a 'sub' component with css applied */
188
+ /** creates a 'sub' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
167
189
  sub: (...p: TSP) => s('sub' as unk as FC<HTP['sub']>)(...p),
168
- /** creates a 'summary' component with css applied */
190
+ /** creates a 'summary' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
169
191
  summary: (...p: TSP) => s('summary' as unk as FC<HTP['summary']>)(...p),
170
- /** creates a 'sup' component with css applied */
192
+ /** creates a 'sup' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
171
193
  sup: (...p: TSP) => s('sup' as unk as FC<HTP['sup']>)(...p),
172
- /** creates a 'table' component with css applied */
194
+ /** creates a 'table' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
173
195
  table: (...p: TSP) => s('table' as unk as FC<HTP['table']>)(...p),
174
- /** creates a 'tbody' component with css applied */
196
+ /** creates a 'tbody' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
175
197
  tbody: (...p: TSP) => s('tbody' as unk as FC<HTP['tbody']>)(...p),
176
- /** creates a 'td' component with css applied */
198
+ /** creates a 'td' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
177
199
  td: (...p: TSP) => s('td' as unk as FC<HTP['td']>)(...p),
178
- /** creates a 'textarea' component with css applied */
200
+ /** creates a 'textarea' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
179
201
  textarea: (...p: TSP) => s('textarea' as unk as FC<HTP['textarea']>)(...p),
180
- /** creates a 'tfoot' component with css applied */
202
+ /** creates a 'tfoot' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
181
203
  tfoot: (...p: TSP) => s('tfoot' as unk as FC<HTP['tfoot']>)(...p),
182
- /** creates a 'th' component with css applied */
204
+ /** creates a 'th' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
183
205
  th: (...p: TSP) => s('th' as unk as FC<HTP['th']>)(...p),
184
- /** creates a 'thead' component with css applied */
206
+ /** creates a 'thead' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
185
207
  thead: (...p: TSP) => s('thead' as unk as FC<HTP['thead']>)(...p),
186
- /** creates a 'time' component with css applied */
208
+ /** creates a 'time' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
187
209
  time: (...p: TSP) => s('time' as unk as FC<HTP['time']>)(...p),
188
- /** creates a 'tr' component with css applied */
210
+ /** creates a 'tr' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
189
211
  tr: (...p: TSP) => s('tr' as unk as FC<HTP['tr']>)(...p),
190
- /** creates a 'u' component with css applied */
212
+ /** creates a 'u' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
191
213
  u: (...p: TSP) => s('u' as unk as FC<HTP['u']>)(...p),
192
- /** creates a 'ul' component with css applied */
214
+ /** creates a 'ul' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
193
215
  ul: (...p: TSP) => s('ul' as unk as FC<HTP['ul']>)(...p),
194
- /** creates a 'video' component with css applied */
216
+ /** creates a 'video' component with css applied; See [npm](https://www.npmjs.com/package/@slimr/styled) for more info. */
195
217
  video: (...p: TSP) => s('video' as unk as FC<HTP['video']>)(...p),
196
218
  })
package/esm/core.d.ts CHANGED
@@ -27,6 +27,9 @@ export interface SCProps extends _Props {
27
27
  _focusWithin?: Zx;
28
28
  /** Like zx prop, but applies only on :hover */
29
29
  _hover?: Zx;
30
+ /** Like zx prop, but applies only when user prefers dark theme */
31
+ _light?: Zx;
32
+ /** Standard style prop */
30
33
  style?: CSSProperties;
31
34
  /** Like zx prop, but applies only on :target */
32
35
  _target?: Zx;
@@ -45,9 +48,9 @@ export type SC<T extends {
45
48
  className?: HTMLAttributes<allowableAny>['className'];
46
49
  }> = FC<T & SCProps>;
47
50
  /**
48
- * A lightweight alternative to styled-components
49
- * @param function - a functional component to be styled; must accept a className prop
50
- * @returns a function that accepts a template string of css returns a decorated functional component
51
+ * The core functionality of the exported `styled` Object.
52
+ *
53
+ * Not intended to be used directly. Instead, use the `styled` object.
51
54
  */
52
55
  export declare function styledBase<C extends FC<allowableAny>>(Component: C): (strings: string | TemplateStringsArray, ...placeHolders: string[]) => SC<Parameters<C>[0]>;
53
56
  export {};
package/esm/core.js CHANGED
@@ -2,55 +2,10 @@
2
2
  import { classJoin, css, shorthandPropsMap } from '@slimr/css';
3
3
  import { toCamelCase, toKebabCase } from '@slimr/util';
4
4
  import { createElement, forwardRef } from 'react';
5
- /** Expands the shorthand props of a zx prop into css full */
6
- function expandShorthandProps(zx) {
7
- return Object.entries(zx).reduce((acc, [k, v]) => {
8
- if (k === 'mx') {
9
- acc.marginLeft = v;
10
- acc.marginRight = v;
11
- }
12
- else if (k === 'my') {
13
- acc.marginTop = v;
14
- acc.marginBottom = v;
15
- }
16
- else if (k === 'px') {
17
- acc.paddingLeft = v;
18
- acc.paddingRight = v;
19
- }
20
- else if (k === 'py') {
21
- acc.paddingTop = v;
22
- acc.paddingBottom = v;
23
- }
24
- else if (k in shorthandPropsMap) {
25
- acc[toCamelCase(shorthandPropsMap[k])] = v;
26
- }
27
- else {
28
- acc[k] = v;
29
- }
30
- return acc;
31
- }, {});
32
- }
33
- /** Converts a zx prop into css string */
34
- function zxToCss(zx) {
35
- return Object.entries(zx)
36
- .map(([k, v]) => {
37
- if (!v)
38
- return '';
39
- k = toKebabCase(k);
40
- if (typeof v === 'number')
41
- v = v + 'px';
42
- if (Array.isArray(v)) {
43
- // @ts-expect-error - TS gets confused by the complexity
44
- v = '[' + v.map(v => (typeof v === 'number' ? v + 'px' : v)).join(',') + ']';
45
- }
46
- return k + ':' + v + ';';
47
- })
48
- .join('\n');
49
- }
50
5
  /**
51
- * A lightweight alternative to styled-components
52
- * @param function - a functional component to be styled; must accept a className prop
53
- * @returns a function that accepts a template string of css returns a decorated functional component
6
+ * The core functionality of the exported `styled` Object.
7
+ *
8
+ * Not intended to be used directly. Instead, use the `styled` object.
54
9
  */
55
10
  export function styledBase(Component) {
56
11
  return (...cssProps) => {
@@ -59,7 +14,7 @@ export function styledBase(Component) {
59
14
  * A functional component that accepts Styled Props
60
15
  */
61
16
  const CStyled = forwardRef(function CStyled(props, ref) {
62
- let { _active, _css, _dark, _focus, _focusVisible, _focusWithin, _hover, _target, _visited, _zx = {}, ...rest } = props;
17
+ let { _active, _css, _dark, _focus, _focusVisible, _focusWithin, _hover, _light, _target, _visited, _zx = {}, ...rest } = props;
63
18
  // Pluck out $ prefixed props
64
19
  Object.entries(props).forEach(([k, v]) => {
65
20
  if (k.startsWith('_')) {
@@ -110,6 +65,13 @@ export function styledBase(Component) {
110
65
  &:hover {
111
66
  ${zxToCss(_hover)}
112
67
  }
68
+ `;
69
+ }
70
+ if (_light) {
71
+ cssStr += `
72
+ @media (prefers-color-scheme: light) {
73
+ ${zxToCss(_light)}
74
+ }
113
75
  `;
114
76
  }
115
77
  if (_target) {
@@ -145,4 +107,52 @@ export function styledBase(Component) {
145
107
  return CStyled;
146
108
  };
147
109
  }
110
+ /**********************
111
+ * Helper Functions
112
+ **********************/
113
+ /** Expands the shorthand props of a zx prop into css full */
114
+ function expandShorthandProps(zx) {
115
+ return Object.entries(zx).reduce((acc, [k, v]) => {
116
+ if (k === 'mx') {
117
+ acc.marginLeft = v;
118
+ acc.marginRight = v;
119
+ }
120
+ else if (k === 'my') {
121
+ acc.marginTop = v;
122
+ acc.marginBottom = v;
123
+ }
124
+ else if (k === 'px') {
125
+ acc.paddingLeft = v;
126
+ acc.paddingRight = v;
127
+ }
128
+ else if (k === 'py') {
129
+ acc.paddingTop = v;
130
+ acc.paddingBottom = v;
131
+ }
132
+ else if (k in shorthandPropsMap) {
133
+ acc[toCamelCase(shorthandPropsMap[k])] = v;
134
+ }
135
+ else {
136
+ acc[k] = v;
137
+ }
138
+ return acc;
139
+ }, {});
140
+ }
141
+ /** Converts a zx prop into css string */
142
+ function zxToCss(zx) {
143
+ return Object.entries(zx)
144
+ .map(([k, v]) => {
145
+ if (!v)
146
+ return '';
147
+ k = toKebabCase(k);
148
+ if (typeof v === 'number')
149
+ v = v + 'px';
150
+ if (Array.isArray(v)) {
151
+ // @ts-expect-error - TS gets confused by the complexity
152
+ v = '[' + v.map(v => (typeof v === 'number' ? v + 'px' : v)).join(',') + ']';
153
+ }
154
+ return k + ':' + v + ';';
155
+ })
156
+ .join('\n');
157
+ }
148
158
  //# sourceMappingURL=core.js.map
package/esm/core.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,EAAiB,SAAS,EAAE,GAAG,EAAE,iBAAiB,EAAC,MAAM,YAAY,CAAA;AAE5E,OAAO,EAAC,WAAW,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AACpD,OAAO,EAAoC,aAAa,EAAE,UAAU,EAAC,MAAM,OAAO,CAAA;AAyDlF,6DAA6D;AAC7D,SAAS,oBAAoB,CAAC,EAAM;IAClC,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QAC/C,IAAI,CAAC,KAAK,IAAI,EAAE;YACd,GAAG,CAAC,UAAU,GAAG,CAAC,CAAA;YAClB,GAAG,CAAC,WAAW,GAAG,CAAC,CAAA;SACpB;aAAM,IAAI,CAAC,KAAK,IAAI,EAAE;YACrB,GAAG,CAAC,SAAS,GAAG,CAAC,CAAA;YACjB,GAAG,CAAC,YAAY,GAAG,CAAC,CAAA;SACrB;aAAM,IAAI,CAAC,KAAK,IAAI,EAAE;YACrB,GAAG,CAAC,WAAW,GAAG,CAAC,CAAA;YACnB,GAAG,CAAC,YAAY,GAAG,CAAC,CAAA;SACrB;aAAM,IAAI,CAAC,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;SAC7E;aAAM;YACL,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;SACX;QACD,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAkC,CAAC,CAAA;AACxC,CAAC;AAED,yCAAyC;AACzC,SAAS,OAAO,CAAC,EAAM;IACrB,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;SACtB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QACd,IAAI,CAAC,CAAC;YAAE,OAAO,EAAE,CAAA;QACjB,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAClB,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;QACvC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACpB,wDAAwD;YACxD,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;SAC7E;QACD,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;IAC1B,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC"}
package/esm/core.ts CHANGED
@@ -42,6 +42,9 @@ export interface SCProps extends _Props {
42
42
  _focusWithin?: Zx
43
43
  /** Like zx prop, but applies only on :hover */
44
44
  _hover?: Zx
45
+ /** Like zx prop, but applies only when user prefers dark theme */
46
+ _light?: Zx
47
+ /** Standard style prop */
45
48
  style?: CSSProperties
46
49
  /** Like zx prop, but applies only on :target */
47
50
  _target?: Zx
@@ -59,50 +62,10 @@ export interface SCProps extends _Props {
59
62
  /** Styled Component: Like FunctionalComponent but adds SCProps */
60
63
  export type SC<T extends {className?: HTMLAttributes<allowableAny>['className']}> = FC<T & SCProps>
61
64
 
62
- /** Expands the shorthand props of a zx prop into css full */
63
- function expandShorthandProps(zx: Zx) {
64
- return Object.entries(zx).reduce((acc, [k, v]) => {
65
- if (k === 'mx') {
66
- acc.marginLeft = v
67
- acc.marginRight = v
68
- } else if (k === 'my') {
69
- acc.marginTop = v
70
- acc.marginBottom = v
71
- } else if (k === 'px') {
72
- acc.paddingLeft = v
73
- acc.paddingRight = v
74
- } else if (k === 'py') {
75
- acc.paddingTop = v
76
- acc.paddingBottom = v
77
- } else if (k in shorthandPropsMap) {
78
- acc[toCamelCase(shorthandPropsMap[k as keyof typeof shorthandPropsMap])] = v
79
- } else {
80
- acc[k] = v
81
- }
82
- return acc
83
- }, {} as Record<string, allowableAny>)
84
- }
85
-
86
- /** Converts a zx prop into css string */
87
- function zxToCss(zx: Zx): string {
88
- return Object.entries(zx)
89
- .map(([k, v]) => {
90
- if (!v) return ''
91
- k = toKebabCase(k)
92
- if (typeof v === 'number') v = v + 'px'
93
- if (Array.isArray(v)) {
94
- // @ts-expect-error - TS gets confused by the complexity
95
- v = '[' + v.map(v => (typeof v === 'number' ? v + 'px' : v)).join(',') + ']'
96
- }
97
- return k + ':' + v + ';'
98
- })
99
- .join('\n')
100
- }
101
-
102
65
  /**
103
- * A lightweight alternative to styled-components
104
- * @param function - a functional component to be styled; must accept a className prop
105
- * @returns a function that accepts a template string of css returns a decorated functional component
66
+ * The core functionality of the exported `styled` Object.
67
+ *
68
+ * Not intended to be used directly. Instead, use the `styled` object.
106
69
  */
107
70
  export function styledBase<C extends FC<allowableAny>>(Component: C) {
108
71
  return (...cssProps: Parameters<typeof css>) => {
@@ -119,6 +82,7 @@ export function styledBase<C extends FC<allowableAny>>(Component: C) {
119
82
  _focusVisible,
120
83
  _focusWithin,
121
84
  _hover,
85
+ _light,
122
86
  _target,
123
87
  _visited,
124
88
  _zx = {},
@@ -179,6 +143,13 @@ export function styledBase<C extends FC<allowableAny>>(Component: C) {
179
143
  }
180
144
  `
181
145
  }
146
+ if (_light) {
147
+ cssStr += `
148
+ @media (prefers-color-scheme: light) {
149
+ ${zxToCss(_light)}
150
+ }
151
+ `
152
+ }
182
153
  if (_target) {
183
154
  cssStr += `
184
155
  &:target {
@@ -218,3 +189,47 @@ export function styledBase<C extends FC<allowableAny>>(Component: C) {
218
189
  return CStyled as unknown as SC<Parameters<C>[0]>
219
190
  }
220
191
  }
192
+
193
+ /**********************
194
+ * Helper Functions
195
+ **********************/
196
+
197
+ /** Expands the shorthand props of a zx prop into css full */
198
+ function expandShorthandProps(zx: Zx) {
199
+ return Object.entries(zx).reduce((acc, [k, v]) => {
200
+ if (k === 'mx') {
201
+ acc.marginLeft = v
202
+ acc.marginRight = v
203
+ } else if (k === 'my') {
204
+ acc.marginTop = v
205
+ acc.marginBottom = v
206
+ } else if (k === 'px') {
207
+ acc.paddingLeft = v
208
+ acc.paddingRight = v
209
+ } else if (k === 'py') {
210
+ acc.paddingTop = v
211
+ acc.paddingBottom = v
212
+ } else if (k in shorthandPropsMap) {
213
+ acc[toCamelCase(shorthandPropsMap[k as keyof typeof shorthandPropsMap])] = v
214
+ } else {
215
+ acc[k] = v
216
+ }
217
+ return acc
218
+ }, {} as Record<string, allowableAny>)
219
+ }
220
+
221
+ /** Converts a zx prop into css string */
222
+ function zxToCss(zx: Zx): string {
223
+ return Object.entries(zx)
224
+ .map(([k, v]) => {
225
+ if (!v) return ''
226
+ k = toKebabCase(k)
227
+ if (typeof v === 'number') v = v + 'px'
228
+ if (Array.isArray(v)) {
229
+ // @ts-expect-error - TS gets confused by the complexity
230
+ v = '[' + v.map(v => (typeof v === 'number' ? v + 'px' : v)).join(',') + ']'
231
+ }
232
+ return k + ':' + v + ';'
233
+ })
234
+ .join('\n')
235
+ }