@ulu/frontend 0.1.0-beta.26 → 0.1.0-beta.28

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/js/ui/popover.js CHANGED
@@ -124,6 +124,7 @@ export class Popover extends Collapsible {
124
124
  createFloatingInstance() {
125
125
  const { content, anchor, contentArrow } = this.elements;
126
126
  const floatingElements = { trigger: anchor, contentArrow, content };
127
+ console.log("this.floatingOptions:\n", this.floatingOptions);
127
128
  this.floatingCleanup = createFloatingUi(floatingElements, this.floatingOptions);
128
129
  }
129
130
  destroyFloatingInstance() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend",
3
- "version": "0.1.0-beta.26",
3
+ "version": "0.1.0-beta.28",
4
4
  "description": "Modular Sass Theming Library",
5
5
  "browser": "js/index.js",
6
6
  "main": "index.js",
package/scss/_utils.scss CHANGED
@@ -128,24 +128,39 @@ $config: (
128
128
 
129
129
  // Returns number unit info, and strips the unit
130
130
  /// @param {String} $number Number to get meta info for
131
- /// @return {Map} With properties (unit, value)
131
+ /// @return {Map} With properties (unit, value, invalid [true/false if not number])
132
132
 
133
- @function number-info($number) {
134
- $is-number: meta.type-of($number) != 'number';
135
- $is-unitless: math.is-unitless($number);
136
- @if ($is-unitless or not $is-number) {
133
+ @function number-info($number, $errors: false) {
134
+
135
+ @if (meta.type-of($number) == 'number') {
136
+ $is-unitless: math.is-unitless($number);
137
137
  @return (
138
- "unit": null,
139
- "value": $number
138
+ "unit": if($is-unitless, null, math.unit($number)),
139
+ "value": if($is-unitless, $number, strip-unit($number)),
140
+ "invalid" : false
140
141
  );
142
+
141
143
  } @else {
144
+ @if ($errors) {
145
+ @error "Expected Number, got #{ meta.type-of($number) } for #{ $number }";
146
+ }
142
147
  @return (
143
- "unit" : math.unit($value),
144
- "value": math.div($number, ($number * 0 + 1))
148
+ "unit": null,
149
+ "value": $number,
150
+ "invalid" : true
145
151
  );
146
152
  }
147
153
  }
148
154
 
155
+ /// Adds unit to unitless number
156
+ /// @param {Number} $number The unitless number to add unit to
157
+ /// @param {String} $unit The unit to add to number
158
+ /// @return {String} Number with unit attached (can't be used in maths)
159
+
160
+ @function add-unit($number, $unit) {
161
+ @return $number + string.unquote($unit);
162
+ }
163
+
149
164
  /// Reusable merge method
150
165
  /// @param {Map} $original Source map
151
166
  /// @param {Map} $changes Changes to merge into source map
@@ -485,4 +500,14 @@ $config: (
485
500
  ) {
486
501
  #{ $property } : $value;
487
502
  #{ $property } : calc(#{ $value } + #{ $responsive-change });
503
+ }
504
+
505
+ /// Calculates the hypotenuse of a triangle
506
+ /// - Can be used to get length between two corners of a rectangle
507
+ /// @param {Number} $width The width of the triangle
508
+ /// @param {Number} $height The height of the triangle
509
+ /// @return {Number} Hypotenuse of a triangle
510
+
511
+ @function hypotenuse($width, $height) {
512
+ @return math.sqrt(math.pow($width, 2) + math.pow($height, 2));
488
513
  }
@@ -29,7 +29,8 @@ $-fallbacks: (
29
29
 
30
30
  /// Module Settings
31
31
  /// @type Map
32
- /// @prop {Dimension} arrow-size [16px] size of the dropdown arrow.
32
+ /// @prop {Dimension} arrow-size [16px] Size of the dropdown arrow.
33
+ /// @prop {Dimension} arrow-mask-overlap [4px] Size that the mask extends beyond the arrow size (which covers up the arrow box shadow inside the popover content). This should be adjusted based on the size of the box-shadow being used)
33
34
  /// @prop {Color} background-color [white] Background color of the popover.
34
35
  /// @prop {Dimension} border-radius [6px] Border radius of the popover.
35
36
  /// @prop {Color} color [inherit] Text color of the popover.
@@ -40,13 +41,12 @@ $-fallbacks: (
40
41
  /// @prop {Dimension} type-size [null] Font size of the popover.
41
42
  /// @prop {Number} z-index [true] z-index of the popover.
42
43
  /// @prop {CssValue} box-shadow [true] Box shadow of the popover.
43
- /// @prop {CssValue} box-shadow-footer [0 0 4px] Box shadow of the popover footer.
44
- /// @prop {String} box-shadow-footer-color ["box-shadow"] Color of the footer's box shadow.
45
44
  /// @prop {Color} header-background-color [#ccc] Background color of the popover header
46
45
  /// @prop {Color} header-color [null] Text color for the header.
47
46
  /// @prop {Color} header-media-background-color [black] background color for header media.
48
47
  /// @prop {Dimension} header-padding-y [0.25rem] Vertical padding of the header.
49
48
  /// @prop {Color} footer-background-color [#ccc] Background color of the footer.
49
+ /// @prop {Color} footer-border-top [1px solid #dfdfdf] Optional border used to separate the content from footer
50
50
  /// @prop {Color} footer-color [null] Text color of the footer.
51
51
  /// @prop {Dimension} footer-padding-y [0.25rem] Vertical padding of the footer.
52
52
  /// @prop {Dimension} footer-padding-y-large [0.5rem] Vertical padding of the footer if using "--large" or "--large-x" styling.
@@ -61,6 +61,7 @@ $-fallbacks: (
61
61
 
62
62
  $config: (
63
63
  "arrow-size" : 16px,
64
+ "arrow-mask-overlap" : 4px,
64
65
  "background-color" : white,
65
66
  "border-radius" : 6px,
66
67
  "color" : inherit,
@@ -70,14 +71,12 @@ $config: (
70
71
  "padding-large" : 2rem,
71
72
  "type-size" : null,
72
73
  "z-index" : true,
73
-
74
74
  "box-shadow" : true,
75
- "box-shadow-footer" : 0 0 4px,
76
- "box-shadow-footer-color" : "box-shadow",
77
75
  "header-background-color" : #ccc,
78
76
  "header-color" : null,
79
77
  "header-media-background-color": black,
80
78
  "header-padding-y" : 0.25rem,
79
+ "footer-border-top" : 1px solid #dfdfdf,
81
80
  "footer-background-color" : #ccc,
82
81
  "footer-color" : null,
83
82
  "footer-padding-y" : 0.25rem,
@@ -117,39 +116,9 @@ $config: (
117
116
 
118
117
  @mixin styles {
119
118
  $prefix: selector.class("popover");
120
- $arrow-size-half: math.div(get("arrow-size"), 2);
121
119
 
122
120
  @if (get("arrow-size")) {
123
- #{ $prefix }__arrow {
124
- display: block;
125
- visibility: hidden;
126
- z-index: 1;
127
- &,
128
- &:before {
129
- position: absolute;
130
- width: get("arrow-size");
131
- height: get("arrow-size");
132
- background: inherit;
133
- }
134
- &:before {
135
- visibility: visible;
136
- content: '';
137
- transform: rotate(45deg);
138
- // box-shadow: $box-shadow;
139
- }
140
- [data-placement^='top'] > & {
141
- bottom: -($arrow-size-half);
142
- }
143
- [data-placement^='bottom'] > & {
144
- top: -($arrow-size-half);
145
- }
146
- [data-placement^='left'] > & {
147
- right: -($arrow-size-half);
148
- }
149
- [data-placement^='right'] > & {
150
- left: -($arrow-size-half);
151
- }
152
- }
121
+ @include -arrow-styles();
153
122
  }
154
123
  // Default position is on the right of the container (Popper handles positioning)
155
124
  #{ $prefix } {
@@ -197,7 +166,7 @@ $config: (
197
166
  background-color: color.get(get("header-media-background-color"));
198
167
  }
199
168
  #{ $prefix }__footer {
200
- box-shadow: get("box-shadow-footer") color.get(get("box-shadow-footer-color"));
169
+ border-top: get("footer-border-top");
201
170
  padding: get("footer-padding-y") get("padding");
202
171
  color: color.get(get("footer-color"));
203
172
  background-color: color.get(get("footer-background-color"));
@@ -260,4 +229,73 @@ $config: (
260
229
  }
261
230
  }
262
231
  }
232
+ }
233
+
234
+ @mixin -arrow-styles() {
235
+ $prefix: selector.class("popover");
236
+ $size: get("arrow-size");
237
+ $half: math.div($size, 2);
238
+ $size-info: utils.number-info($size);
239
+ $unitless: map.get($size-info, "value");
240
+ $unit: map.get($size-info, "unit");
241
+ $hypotenuse: utils.hypotenuse($unitless, $unitless);
242
+ $hypotenuse-half: math.div($hypotenuse, 2);
243
+ $overlap: utils.strip-unit(get("arrow-mask-overlap"));
244
+ $mask-height: utils.add-unit($hypotenuse-half + $overlap, $unit);
245
+ $mask-width: utils.add-unit($hypotenuse + $overlap, $unit);
246
+
247
+ #{ $prefix }__arrow {
248
+ visibility: hidden;
249
+ z-index: 1;
250
+ &,
251
+ &:before,
252
+ &:after {
253
+ display: block;
254
+ position: absolute;
255
+ width: $size;
256
+ height: $size;
257
+ background: inherit;
258
+ }
259
+ &:before,
260
+ &:after {
261
+ visibility: visible;
262
+ content: '';
263
+ }
264
+ &:before {
265
+ box-shadow: get("box-shadow");
266
+ transform: rotate(45deg);
267
+ }
268
+ // Masking shape
269
+ &:after {
270
+ top: 50%;
271
+ left: 50%;
272
+ transform: translateX(-50%);
273
+ height: $mask-height;
274
+ width: $mask-width;
275
+ }
276
+ [data-placement^="top"] > & {
277
+ bottom: -($half);
278
+ transform: rotate(180deg); // Rotate w. mask
279
+ }
280
+ [data-placement^="bottom"] > & {
281
+ top: -($half);
282
+ }
283
+ [data-placement^="left"] > & {
284
+ right: -($half);
285
+ transform: rotate(90deg); // Rotate w. mask
286
+ }
287
+ [data-placement^="right"] > & {
288
+ left: -($half);
289
+ transform: rotate(-90deg); // Rotate w. mask
290
+ }
291
+ }
292
+ // Account for footer and change arrow color when positioned next to it
293
+ #{ $prefix }__footer ~ #{ $prefix }__arrow {
294
+ [data-placement^="top"] > & {
295
+ &:before,
296
+ &:after {
297
+ background-color: get("footer-background-color");
298
+ }
299
+ }
300
+ }
263
301
  }
@@ -1 +1 @@
1
- {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../js/ui/popover.js"],"names":[],"mappings":"AA6BA;;GAEG;AACH,6BAGC;AAED;;;;GAIG;AACH,8BAWC;AAED;;GAEG;AACH;;;;;;;;;EAkBC;AAKD,uDAmBC;AA5FD;;GAEG;AACH,4BAAqC;AA4FrC;;GAEG;AACH;IACE,8DAIC;IADC,qBAA4C;IAa9C,+BAIC;IADC,0BAA+E;IAEjF,gCAKC;CACF;4BAhI2B,kBAAkB"}
1
+ {"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../js/ui/popover.js"],"names":[],"mappings":"AA6BA;;GAEG;AACH,6BAGC;AAED;;;;GAIG;AACH,8BAWC;AAED;;GAEG;AACH;;;;;;;;;EAkBC;AAKD,uDAmBC;AA5FD;;GAEG;AACH,4BAAqC;AA4FrC;;GAEG;AACH;IACE,8DAIC;IADC,qBAA4C;IAa9C,+BAKC;IADC,0BAA+E;IAEjF,gCAKC;CACF;4BAjI2B,kBAAkB"}