@ulu/frontend 0.0.11 → 0.0.13

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.
@@ -25,20 +25,18 @@ export class CssBreakpoints {
25
25
  valueFromPsuedo: false,
26
26
  customProperty: "--breakpoint",
27
27
  psuedoSelector: ':before',
28
+ order: ["small", "medium", "large"],
28
29
  debug: false
29
30
  }
30
31
  /**
31
32
  * @param {Object} config Configruation object
32
- * @param {Array} config.order Required, Array of strings that correspond to the breakpoints setup in the styles, Breakpoints from smallest to largest
33
+ * @param {Array} config.order Array of strings that correspond to the breakpoints setup in the styles, Breakpoints from smallest to largest, defaults to [small, medium, large]
33
34
  * @param {Array} config.customProperty Property to grab breakpoint from (default is --breakpoint)
34
35
  * @param {Array} config.valueFromPsuedo Use the legacy method of grabbing breakpoint from psuedo element, default uses custom property
35
36
  * @param {Node} config.element The element to retrieve active breakpoint from stylesheet. (default is html) For using the old psuedo method, adjust this to document.body
36
37
  * @param {String} config.psuedoSelector Change psuedo selector used to get the breakpoint from the psuedo's content property
37
38
  */
38
39
  constructor(config) {
39
- if (!config.order) {
40
- logError(this, 'Missing order (required)!');
41
- }
42
40
  Object.assign(this, CssBreakpoints.defaults, config);
43
41
  this.active = null;
44
42
  this.previous = null;
@@ -119,6 +117,7 @@ export class CssBreakpoints {
119
117
  /**
120
118
  * Get a breakpoint by key
121
119
  * @param {String} name The name of the breakpoint to get
120
+ * @return {Breakpoint} Breakpoint to act on (see BreakpointDirection)
122
121
  */
123
122
  at(name) {
124
123
  const bp = this.breakpoints[name];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Theming library",
5
5
  "browser": "js/index.js",
6
6
  "main": "index.js",
@@ -10,11 +10,12 @@ export class CssBreakpoints {
10
10
  valueFromPsuedo: boolean;
11
11
  customProperty: string;
12
12
  psuedoSelector: string;
13
+ order: string[];
13
14
  debug: boolean;
14
15
  };
15
16
  /**
16
17
  * @param {Object} config Configruation object
17
- * @param {Array} config.order Required, Array of strings that correspond to the breakpoints setup in the styles, Breakpoints from smallest to largest
18
+ * @param {Array} config.order Array of strings that correspond to the breakpoints setup in the styles, Breakpoints from smallest to largest, defaults to [small, medium, large]
18
19
  * @param {Array} config.customProperty Property to grab breakpoint from (default is --breakpoint)
19
20
  * @param {Array} config.valueFromPsuedo Use the legacy method of grabbing breakpoint from psuedo element, default uses custom property
20
21
  * @param {Node} config.element The element to retrieve active breakpoint from stylesheet. (default is html) For using the old psuedo method, adjust this to document.body
@@ -52,8 +53,91 @@ export class CssBreakpoints {
52
53
  /**
53
54
  * Get a breakpoint by key
54
55
  * @param {String} name The name of the breakpoint to get
56
+ * @return {Breakpoint} Breakpoint to act on (see BreakpointDirection)
55
57
  */
56
- at(name: string): any;
58
+ at(name: string): Breakpoint;
57
59
  }
58
60
  export default CssBreakpoints;
61
+ /**
62
+ * @class
63
+ * Single breakpoint management
64
+ */
65
+ declare class Breakpoint {
66
+ constructor(name: any, manager: any);
67
+ directions: {
68
+ max: BreakpointDirection;
69
+ min: BreakpointDirection;
70
+ only: BreakpointDirection;
71
+ };
72
+ _manager: any;
73
+ name: any;
74
+ /**
75
+ * Private method used inrternally for managing direction activation
76
+ * - Each direction manages it's own state and handlers
77
+ * @param {String} direction The directional key
78
+ * @param {Boolean} active State of that direction to set
79
+ */
80
+ _setDirection(direction: string, active: boolean): void;
81
+ /**
82
+ * Attach handler to be executed from the breakpoint and to all breakpoints below.
83
+ * - If the browser resizes from a breakpoint below this breakpoint,
84
+ * and above the breakpoint name specified, this handler will fire
85
+ * @param {Function} handler Handler to be executed
86
+ */
87
+ max(handler: Function): void;
88
+ /**
89
+ * Attach handler to be executed from the breakpoint and to all breakpoints below.
90
+ * - If the browser resizes from a breakpoint above this breakpoint,
91
+ * and below the breakpoint name specified, this handler will fire
92
+ * @param {Function} handler Handler to be executed
93
+ */
94
+ min(handler: Function): void;
95
+ /**
96
+ * Attach a handler to fire when the breakpoint is within the key
97
+ * @param {Function} handler Handler to be executed
98
+ */
99
+ only(handler: Function): void;
100
+ /**
101
+ * Remove handler
102
+ * @param {Function} handler Handler to be removed, extended on/off object style can be used
103
+ * @param {String} direction Remove handler only from specified direction, else search all directions
104
+ */
105
+ remove(handler: Function, direction: string): void;
106
+ log(...msg: any[]): void;
107
+ }
108
+ /**
109
+ * @class
110
+ * Used to handle a breakpoints direction's handler and state
111
+ */
112
+ declare class BreakpointDirection {
113
+ constructor(direction: any, breakpoint: any);
114
+ direction: any;
115
+ active: boolean;
116
+ on: any[];
117
+ off: any[];
118
+ breakpoint: any;
119
+ /**
120
+ * Change the state of the direction
121
+ */
122
+ change(to: any): void;
123
+ /**
124
+ * Calls all functions in handlers or
125
+ */
126
+ _call(forActive: any): void;
127
+ /**
128
+ * Returns handlers in normalized object format on/off
129
+ */
130
+ getHandlers(handler: any): any;
131
+ /**
132
+ * Adds a handler for the direction, optionally use object to add off state handler
133
+ * @param {Function|Object} handler Function to be executed when direction is active, read object description for on/off
134
+ * @param {Function|Object} handler.on Function to be executed when direction is active
135
+ * @param {Function|Object} handler.off Function to be executed when direction was active and is now changed to inactive
136
+ */
137
+ add(handler: Function | any): void;
138
+ /**
139
+ * Removes a handler
140
+ */
141
+ remove(handler: any): void;
142
+ }
59
143
  //# sourceMappingURL=css-breakpoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"css-breakpoint.d.ts","sourceRoot":"","sources":["../../js/helpers/css-breakpoint.js"],"names":[],"mappings":"AAeA;;;;GAIG;AACH;IACE,wBAAsB;IACtB;;;;;;MAMC;IACD;;;;;;;OAOG;IACH;QANyB,KAAK;QACL,cAAc;QACd,eAAe;QAChB,OAAO,EAApB,IAAI;QACW,cAAc;OAiBvC;IAVC,YAAkB;IAClB,cAAoB;IACpB,iBAAuB;IACvB,wBAA2B;IAC3B,mBAAyB;IACzB,gBAAqB;IAMvB;;OAEG;IACH,gCAEC;IACD;;OAEG;IACH,kCAEC;IACD;;OAEG;IACH,wBAMC;IACD;;OAEG;IACH,eAuCC;IACD;;;OAGG;IACH,sBAMC;CACF"}
1
+ {"version":3,"file":"css-breakpoint.d.ts","sourceRoot":"","sources":["../../js/helpers/css-breakpoint.js"],"names":[],"mappings":"AAeA;;;;GAIG;AACH;IACE,wBAAsB;IACtB;;;;;;;MAOC;IACD;;;;;;;OAOG;IACH;QANyB,KAAK;QACL,cAAc;QACd,eAAe;QAChB,OAAO,EAApB,IAAI;QACW,cAAc;OAcvC;IAVC,YAAkB;IAClB,cAAoB;IACpB,iBAAuB;IACvB,wBAA2B;IAC3B,mBAAyB;IACzB,gBAAqB;IAMvB;;OAEG;IACH,gCAEC;IACD;;OAEG;IACH,kCAEC;IACD;;OAEG;IACH,wBAMC;IACD;;OAEG;IACH,eAuCC;IACD;;;;OAIG;IACH,kBAFY,UAAU,CAQrB;CACF;;AAsED;;;GAGG;AACH;IACE,qCAQC;IAPC;;;;MAIC;IACD,cAAuB;IACvB,UAAgB;IAElB;;;;;OAKG;IACH,wDAEC;IACD;;;;;OAKG;IACH,6BAEC;IACD;;;;;OAKG;IACH,6BAEC;IACD;;;OAGG;IACH,8BAEC;IACD;;;;OAIG;IACH,mDAGC;IAED,yBAGC;CACF;AAnID;;;GAGG;AACH;IACE,6CAMC;IALC,eAA0B;IAC1B,gBAAmB;IACnB,UAAY;IACZ,WAAa;IACb,gBAA4B;IAE9B;;OAEG;IACH,sBAMC;IACD;;OAEG;IACH,4BAIC;IACD;;OAEG;IACH,+BAEC;IACD;;;;;OAKG;IACH,aAJW,cAAe,QAiBzB;IACD;;OAEG;IACH,2BAQC;CACF"}