stalefish 7.2.1 → 7.4.0

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.
@@ -0,0 +1,47 @@
1
+ import { html, css } from 'halfcab'
2
+
3
+ const width = 375
4
+
5
+ // language=CSS
6
+ const styles = css`
7
+ .sideDrawer {
8
+ transition: left 0.2s ease, opacity 0.4s ease;
9
+ position: fixed;
10
+ top: 0;
11
+ left: 0;
12
+ z-index: 20000;
13
+ width: ${width}px;
14
+ height: 100vh;
15
+ background-color: black;
16
+ color: white;
17
+ }
18
+
19
+ .closeButton {
20
+ width: 20px;
21
+ height: 20px;
22
+ position: absolute;
23
+ right: 10px;
24
+ top: 10px;
25
+ cursor: pointer;
26
+ }
27
+
28
+ .content {
29
+ position: absolute;
30
+ left: 0;
31
+ top: 30px;
32
+ }
33
+ `
34
+
35
+ export default ({ on, topPadding, closeIcon, closeAction, content }) => html`
36
+ <div class="${styles.sideDrawer}"
37
+ style="opacity: ${on ? '0.9' : '0'};left: ${on ? '0px' : `calc(-1 * (${width}px + 10px))`};${topPadding ? `padding-top: ${topPadding}` : ''}">
38
+ <div style="width: 100%; position: relative;">
39
+ <div class="${styles.closeButton}"
40
+ onclick=${e => closeAction && closeAction(e)}>${closeIcon}
41
+ </div>
42
+ <div class="${styles.content}">
43
+ ${content}
44
+ </div>
45
+ </div>
46
+ </div>
47
+ `
@@ -65,7 +65,7 @@ class Textarea extends Component {
65
65
  this.onchange = args.onchange
66
66
  this.oninput = args.oninput
67
67
 
68
- let { holdingPen, label, placeholder, property, required, pattern, onkeyup, autofocus, permanentTopPlaceholder = false, permanentTopLabel = false, disabled } = args
68
+ let { holdingPen, label, placeholder, property, required, pattern, onkeyup, autofocus, permanentTopPlaceholder = false, permanentTopLabel = false, disabled, darkBackground } = args
69
69
 
70
70
  let input = html`<textarea data-gramm="false" style="${this.height ? `height: ${this.height}` : ''}" class="${styles.textarea} ${fieldIsTouched(holdingPen, property) === true ? styles.touched : ''}" onkeyup=${e => onkeyup && onkeyup(e)} ${required ? { required: 'required' } : ''} onchange=${e => { change({ e, holdingPen, property, label: styles.label }); this.onchange && this.onchange(e) }} oninput=${e => { this.height = window.getComputedStyle(this.element.querySelector('textarea')).height; change({ e, holdingPen, property, label: styles.label }); this.oninput && this.oninput(e) }} onblur=${formField(holdingPen, property)} placeholder="${placeholder || ''}${required ? ' *' : ''}" ${pattern ? { pattern } : ''}>${holdingPen[property] || ''}</textarea>`
71
71
 
@@ -74,7 +74,7 @@ class Textarea extends Component {
74
74
  }
75
75
 
76
76
  return html`
77
- <label ${disabled ? { disabled } : ''} style="${disabled ? 'cursor: not-allowed; opacity: 0.3;' : ''}width: 100%; text-align: left; display: inline-block;"><span class="${styles.label}" style="opacity: ${holdingPen[property] === 0 || holdingPen[property] || (permanentTopPlaceholder || permanentTopLabel) ? 1 : 0}; font-size: 16px; font-weight: normal; color: #999; margin-left: 5px; padding: 9px; background-color: rgba(255,255,255,0.8); ">${label}${required ? ' *' : ''}</span>${input}</label>
77
+ <label ${disabled ? { disabled } : ''} style="${disabled ? 'cursor: not-allowed; opacity: 0.3;' : ''}width: 100%; text-align: left; display: inline-block;"><span class="${styles.label}" style="opacity: ${holdingPen[property] === 0 || holdingPen[property] || (permanentTopPlaceholder || permanentTopLabel) ? 1 : 0}; font-size: 16px; font-weight: normal; color: #999; margin-left: 5px; padding: 9px; background-color: rgba(255,255,255,${darkBackground ? 1 : 0.8}); ">${label}${required ? ' *' : ''}</span>${input}</label>
78
78
  `
79
79
  }
80
80
 
@@ -6,65 +6,65 @@ let cache = new LRU(300)
6
6
 
7
7
  // language=CSS
8
8
  let styles = css`
9
- .textfield {
10
- padding: 10px;
11
- border: solid 5px #c9c9c9;
12
- transition: border 0.3s;
13
- outline: none;
14
- width: 100%;
15
- font-size: 18px;
16
- border-radius: 0;
17
- box-shadow: none !important;
18
- font-weight: normal;
19
- box-sizing: border-box;
20
- font-family: inherit;
21
- line-height: 1.4em;
22
- -webkit-appearance: none;
23
- -moz-appearance: none;
24
- appearance: none;
25
- z-index: 20;
26
- position: relative;
27
- }
9
+ .textfield {
10
+ padding: 10px;
11
+ border: solid 5px #c9c9c9;
12
+ transition: border 0.3s;
13
+ outline: none;
14
+ width: 100%;
15
+ font-size: 18px;
16
+ border-radius: 0;
17
+ box-shadow: none !important;
18
+ font-weight: normal;
19
+ box-sizing: border-box;
20
+ font-family: inherit;
21
+ line-height: 1.4em;
22
+ -webkit-appearance: none;
23
+ -moz-appearance: none;
24
+ appearance: none;
25
+ z-index: 20;
26
+ position: relative;
27
+ }
28
28
 
29
- .label {
30
- transition: opacity 0.75s;
31
- border-top-right-radius: 5px;
32
- border-top-left-radius: 5px;
33
- user-select: none;
34
- position: absolute;
35
- top: -55px;
36
- z-index: 10;
37
- }
29
+ .label {
30
+ transition: opacity 0.75s;
31
+ border-top-right-radius: 5px;
32
+ border-top-left-radius: 5px;
33
+ user-select: none;
34
+ position: absolute;
35
+ top: -55px;
36
+ z-index: 10;
37
+ }
38
38
 
39
- .textfield.highlight {
40
- border-color: #ff4081;
41
- }
39
+ .textfield.highlight {
40
+ border-color: #ff4081;
41
+ }
42
42
 
43
- .textfield:focus {
44
- border: solid 5px #969696;
45
- }
43
+ .textfield:focus {
44
+ border: solid 5px #969696;
45
+ }
46
46
 
47
- .textfield::placeholder {
48
- color: #999;
49
- }
47
+ .textfield::placeholder {
48
+ color: #999;
49
+ }
50
50
 
51
- .textfield.touched:invalid:not(:focus) {
52
- border-color: red;
53
- }
51
+ .textfield.touched:invalid:not(:focus) {
52
+ border-color: red;
53
+ }
54
54
 
55
- .valueContext {
56
- position: absolute;
57
- color: #AAA;
58
- font-size: 1.1em;
59
- line-height: 1.2em;
60
- font-weight: normal;
61
- box-sizing: border-box;
62
- top: -12px;
63
- right: 7px;
64
- background-color: #EEE;
65
- padding: 10px;
66
- z-index: 30;
67
- }
55
+ .valueContext {
56
+ position: absolute;
57
+ color: #AAA;
58
+ font-size: 1.1em;
59
+ line-height: 1.2em;
60
+ font-weight: normal;
61
+ box-sizing: border-box;
62
+ top: -12px;
63
+ right: 7px;
64
+ background-color: #EEE;
65
+ padding: 10px;
66
+ z-index: 30;
67
+ }
68
68
  `
69
69
 
70
70
  function change ({ e, holdingPen, property, label }) {
@@ -105,7 +105,7 @@ class Textfield extends Component {
105
105
  this.oninput = args.oninput
106
106
  this.onchange = args.onchange
107
107
 
108
- let { highlightBorder = false, wrapperStyle = null, holdingPen, label, placeholder, property, required, pattern, type, autofocus, valueContext, permanentTopPlaceholder = false, permanentTopLabel = false, disabled, maxCharacters, maxNumber, minNumber } = args
108
+ let { highlightBorder = false, wrapperStyle = null, holdingPen, label, placeholder, property, required, pattern, type, autofocus, valueContext, permanentTopPlaceholder = false, permanentTopLabel = false, disabled, maxCharacters, maxNumber, minNumber, darkBackground } = args
109
109
 
110
110
  let input = html`<input data-gramm="false" ${disabled ? { disabled } : ''} ${maxNumber ? { max: maxNumber } : ''} ${minNumber ? { min: minNumber } : ''} ${maxCharacters ? { maxlength: maxCharacters } : ''} style="${disabled ? 'cursor: not-allowed; opacity: 0.3;' : ''}" class="${styles.textfield} ${fieldIsTouched(holdingPen, property) === true ? styles.touched : ''} ${highlightBorder ? styles.highlight : ''}" value="${holdingPen[property] !== undefined && holdingPen[property] !== null ? holdingPen[property] : ''}" onkeyup=${e => this.onkeyup && this.onkeyup(e)} ${required ? { required: 'required' } : ''} onchange=${e => { change({ e, holdingPen, property, label: styles.label }); this.onchange && this.onchange(e) }} oninput=${e => { change({ e, holdingPen, property, label: styles.label }); this.oninput && this.oninput(e) }} onblur=${formField(holdingPen, property)} placeholder="${placeholder || ''}${required ? ' *' : ''}" type="${determineType(type)}" ${pattern ? { pattern } : ''} ${type.toLowerCase() === 'number' ? { step: determineStep(type) } : ''} />`
111
111
 
@@ -114,14 +114,14 @@ class Textfield extends Component {
114
114
  }
115
115
 
116
116
  return html`
117
- <div ${wrapperStyle ? { 'class': wrapperStyle } : ''} style="display: inline-block; width: calc(100% - 10px); margin: 40px 5px 5px 5px;">
118
- <label style="width: 100%; text-align: left; position: relative; padding: 0;">
119
- ${valueContext ? html`<div class="${styles.valueContext}">${valueContext}</div>` : ''}
120
- ${label ? html`<span class="${styles.label}" style="opacity: ${holdingPen[property] === 0 || holdingPen[property] || (permanentTopPlaceholder || permanentTopLabel) ? 1 : 0}; font-size: 16px; font-weight: normal; color: #999; margin-left: 5px; padding: 9px; background-color: rgba(255,255,255,0.8); ">${label}${required ? ' *' : ''}</span>` : ''}
121
- ${input}
122
- </label>
123
- </div>
124
- `
117
+ <div ${wrapperStyle ? { 'class': wrapperStyle } : ''} style="display: inline-block; width: calc(100% - 10px); margin: ${label ? '40' : '5'}px 5px 5px 5px;">
118
+ <label style="width: 100%; text-align: left; position: relative; padding: 0;">
119
+ ${valueContext ? html`<div class="${styles.valueContext}">${valueContext}</div>` : ''}
120
+ ${label ? html`<span class="${styles.label}" style="opacity: ${holdingPen[property] === 0 || holdingPen[property] || (permanentTopPlaceholder || permanentTopLabel) ? 1 : 0}; font-size: 16px; font-weight: normal; color: #999; margin-left: 5px; padding: 9px; background-color: rgba(255,255,255,${darkBackground ? 1 : 0.8}); ">${label}${required ? ' *' : ''}</span>` : ''}
121
+ ${input}
122
+ </label>
123
+ </div>
124
+ `
125
125
  }
126
126
 
127
127
  update (args) {
package/index.mjs CHANGED
@@ -19,6 +19,7 @@ import down from './components/icons/down.mjs'
19
19
  import calendarIcon from './components/icons/calendarIcon.mjs'
20
20
  import timeIcon from './components/icons/timeIcon.mjs'
21
21
  import solidDown from './components/icons/solidDown.mjs'
22
+ import sideDrawer from './components/sideDrawer.mjs'
22
23
 
23
24
  export {
24
25
  button,
@@ -41,5 +42,6 @@ export {
41
42
  calendarIcon,
42
43
  timeIcon,
43
44
  solidDown,
44
- uploader
45
+ uploader,
46
+ sideDrawer
45
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stalefish",
3
- "version": "7.2.1",
3
+ "version": "7.4.0",
4
4
  "description": "Simple function based component library for halfcab tagged template literals",
5
5
  "main": "index.mjs",
6
6
  "module": "index.mjs",