@inizioevoke/astro-core 1.7.0 → 2.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inizioevoke/astro-core",
3
- "version": "1.7.0",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -11,13 +11,11 @@
11
11
  "./integrations": "./src/integrations/index.ts",
12
12
  "./lib": "./src/lib/index.ts",
13
13
  "./lib/FlipCard": "./src/components/FlipCard/index.ts",
14
+ "./lib/ISI": "./src/components/ISI/index.ts",
14
15
  "./lib/Modal": "./src/components/Modal/index.ts",
15
16
  "./lib/PdfViewer": "./src/components/PdfViewer/index.ts",
16
17
  "./lib/ScrollContainer": "./src/components/ScrollContainer/index.ts",
17
- "./lib/gestures": "./src/lib/gestures/index.ts",
18
- "./v2": "./src/components/v2.ts",
19
- "./v2/lib": "./src/lib/v2.ts",
20
- "./v2/lib/Modal": "./src/components/Modal/v2/index.ts"
18
+ "./lib/gestures": "./src/lib/gestures/index.ts"
21
19
  },
22
20
  "files": [
23
21
  "src",
@@ -1,6 +1,12 @@
1
1
  const TAG_NAME = 'evo-flip-card';
2
2
 
3
- export class EvoFlipCardElement extends HTMLElement {
3
+ export interface IEvoFlipCardElement {
4
+ isFlipped: boolean;
5
+ toggle: () => void;
6
+ flipFront: () => void;
7
+ flipBack: () => void;
8
+ }
9
+ export class EvoFlipCardElement extends HTMLElement implements IEvoFlipCardElement {
4
10
 
5
11
  static get observedAttributes(): string[] {
6
12
  return ['flipped'];
@@ -34,26 +40,26 @@ export class EvoFlipCardElement extends HTMLElement {
34
40
  }
35
41
  }
36
42
 
37
- get flipped() {
43
+ get isFlipped() {
38
44
  return this.#flipped;
39
45
  }
40
- set flipped(value: boolean | string) {
41
- this.#flipped = typeof value == 'string' ? value.toLowerCase() === 'true' : value === true;
46
+ set isFlipped(value: boolean) {
47
+ this.#flipped = value === true;
42
48
  this.setAttribute('flipped', this.#flipped.toString());
43
49
  }
44
50
 
45
- toggleFlipped() {
46
- this.flipped = !this.flipped;
51
+ toggle() {
52
+ this.isFlipped = !this.isFlipped;
47
53
  }
48
54
  flipFront() {
49
- this.flipped = false;
55
+ this.isFlipped = false;
50
56
  }
51
57
  flipBack() {
52
- this.flipped = true;
58
+ this.isFlipped = true;
53
59
  }
54
60
 
55
61
  #handleTriggerClick() {
56
- this.toggleFlipped();
62
+ this.toggle();
57
63
  }
58
64
  }
59
65
  if (!customElements.get(TAG_NAME)) {
@@ -1,31 +1,38 @@
1
1
  ---
2
- import type { HTMLTag } from 'astro/types';
2
+ import type { HTMLAttributes } from 'astro/types';
3
3
  import ScrollContainer, { type Props as ScrollContainerProps } from '../ScrollContainer/ScrollContainer.astro';
4
4
  import './RightISI.css';
5
5
 
6
- interface Props {
7
- tag?: HTMLTag;
6
+ interface Props extends HTMLAttributes<'div'> {
8
7
  scrollContainer?: ScrollContainerProps;
9
8
  headerButton?: boolean;
9
+ transitionDuration?: number
10
10
  }
11
11
 
12
12
  const {
13
- tag: TagName = 'aside',
14
13
  scrollContainer,
15
- headerButton = false
14
+ headerButton = false,
15
+ transitionDuration = 500,
16
+ ...rest
16
17
  } = Astro.props;
17
18
 
19
+ const attrs = {
20
+ ...rest,
21
+ 'data-transition-duration': transitionDuration.toString()
22
+ };
23
+
24
+ attrs.style = `--evo-isi-transition-duration:${transitionDuration}ms;${attrs.style ?? ''}`;
25
+
18
26
  const renderHeaderButton = Astro.slots.has('header-button') || headerButton;
19
27
  const renderHeader = Astro.slots.has('header') || renderHeaderButton;
20
28
  ---
21
- <TagName class="evo-isi">
29
+ <evo-isi {...attrs}>
22
30
  <div class="evo-isi-wrapper">
23
-
24
31
  {renderHeader && <div class="evo-isi-header">
25
32
  <slot name="header" />
26
33
  {renderHeaderButton &&
27
34
  <div class="evo-isi-header-button">
28
- <slot name="header-button"><button>Expand</button></slot>
35
+ <slot name="header-button"><button class="evo-isi-toggle">Expand</button></slot>
29
36
  </div>}
30
37
  </div>}
31
38
  <div class="evo-isi-text">
@@ -37,7 +44,7 @@ const renderHeader = Astro.slots.has('header') || renderHeaderButton;
37
44
  <slot name="footer" />
38
45
  </div>}
39
46
  </div>
40
- </TagName>
47
+ </evo-isi>
41
48
  <script>
42
49
  import './RightISI';
43
50
  </script>
@@ -0,0 +1,61 @@
1
+ @layer inizioevoke-astro-components {
2
+ :root {
3
+ --evo-isi-width: 25vw;
4
+ --evo-isi-width-expanded: 100vw;
5
+ --evo-isi-height: 100vh;
6
+ --evo-isi-header-height: 0px;
7
+ --evo-isi-header-padding-top: 0px;
8
+ --evo-isi-header-padding-bottom: 0px;
9
+ --evo-isi-text-padding-top: 0px;
10
+ --evo-isi-text-padding-bottom: 0px;
11
+ --evo-isi-footer-height: 0px;
12
+ --evo-isi-footer-padding-top: 0px;
13
+ --evo-isi-footer-padding-bottom: 0px;
14
+ --evo-isi-transition-duration: 500ms;
15
+ }
16
+ evo-isi {
17
+ position: fixed;
18
+ right: 0;
19
+ top: 0;
20
+ display: block;
21
+ width: var(--evo-isi-width);
22
+ height: var(--evo-isi-height);
23
+ overflow: hidden;
24
+ z-index: 99;
25
+ background-color: #ffffff;
26
+
27
+ transform-origin: right top;
28
+ transition-property: width;
29
+ transition-duration: var(--evo-isi-transition-duration);
30
+ transition-timing-function: ease-in-out;
31
+
32
+ .evo-isi-wrapper {
33
+ .evo-isi-header {
34
+ height: var(--evo-isi-header-height);
35
+ }
36
+ .evo-isi-text {
37
+ height: calc(
38
+ var(--evo-isi-height) -
39
+ var(--evo-isi-header-height) -
40
+ var(--evo-isi-header-padding-top) -
41
+ var(--evo-isi-header-padding-bottom) -
42
+ var(--evo-isi-text-padding-top) -
43
+ var(--evo-isi-text-padding-bottom) -
44
+ var(--evo-isi-footer-height) -
45
+ var(--evo-isi-footer-padding-top) -
46
+ var(--evo-isi-footer-padding-bottom)
47
+ );
48
+ evo-scroll-container {
49
+
50
+ }
51
+ }
52
+ .evo-isi-footer {
53
+ height: var(--evo-isi-footer-height);
54
+ }
55
+ }
56
+
57
+ &.evo-isi-expand {
58
+ width: var(--evo-isi-width-expanded);
59
+ }
60
+ }
61
+ }
@@ -2,7 +2,6 @@
2
2
 
3
3
  ```jsx
4
4
  <RightISI
5
- tag="aside" // optional
6
5
  scrollContainer={{ // optional
7
6
  /* ScrollContainer props */
8
7
  }}
@@ -0,0 +1,78 @@
1
+ import { EvoScrollContainerElement } from '../../ScrollContainer/ScrollContainer';
2
+ import type { IEvoIsiElement } from '../index';
3
+
4
+ const TAG_NAME = 'evo-isi';
5
+
6
+ export class EvoIsiElement extends HTMLElement implements IEvoIsiElement {
7
+ #scrollContainer!: EvoScrollContainerElement;
8
+ #transitionDuration = 500;
9
+
10
+ constructor() {
11
+ super();
12
+ }
13
+
14
+ connectedCallback() {
15
+ this.#transitionDuration = parseInt(this.dataset.transitionDuration ?? '500', 10);
16
+ this.#scrollContainer = this.querySelector('evo-scroll-container') as EvoScrollContainerElement;
17
+ this.querySelector<HTMLButtonElement>('.evo-isi-toggle')?.addEventListener('click', (e) => {
18
+ e.preventDefault();
19
+ this.toggle();
20
+ });
21
+ }
22
+
23
+ toggle() {
24
+ if (!this.classList.contains('evo-isi-expand')) {
25
+ return this.expand();
26
+ } else {
27
+ return this.collapse();
28
+ }
29
+ }
30
+
31
+ expand() {
32
+ return new Promise<void>((resolve) => {
33
+ if (!this.classList.contains('evo-isi-expand')) {
34
+ this.classList.add('evo-isi-expand');
35
+ let animating = true;
36
+ const refresh = () => {
37
+ if (animating) {
38
+ this.#scrollContainer.refresh();
39
+ requestAnimationFrame(refresh);
40
+ }
41
+ }
42
+ refresh();
43
+ setTimeout(() => {
44
+ animating = false;
45
+ resolve();
46
+ }, this.#transitionDuration);
47
+ } else {
48
+ resolve();
49
+ }
50
+ });
51
+ }
52
+
53
+ collapse() {
54
+ return new Promise<void>((resolve) => {
55
+ if (this.classList.contains('evo-isi-expand')) {
56
+ this.classList.remove('evo-isi-expand');
57
+ this.#scrollContainer.scrollTo({ top: 0, behavior: 'smooth' });
58
+ let animating = true;
59
+ const refresh = () => {
60
+ if (animating) {
61
+ this.#scrollContainer.refresh();
62
+ requestAnimationFrame(refresh);
63
+ }
64
+ }
65
+ refresh();
66
+ setTimeout(() => {
67
+ animating = false;
68
+ resolve();
69
+ }, this.#transitionDuration);
70
+ } else {
71
+ resolve();
72
+ }
73
+ });
74
+ }
75
+ }
76
+ if (!customElements.get(TAG_NAME)) {
77
+ customElements.define(TAG_NAME, EvoIsiElement);
78
+ }
@@ -0,0 +1 @@
1
+ export * from './RightISI';
@@ -0,0 +1,5 @@
1
+ export interface IEvoIsiElement {
2
+ toggle: () => void;
3
+ expand: () => void;
4
+ collapse: () => void;
5
+ }
@@ -4,13 +4,13 @@ import './Modal.css';
4
4
 
5
5
  interface Props extends HTMLAttributes<'div'> {
6
6
  id: string;
7
- closeButton?: boolean;
7
+ closeButton?: 'default' | 'minimal' | 'none' | 'false' | false;
8
8
  closeButtonAtts?: Record<string, string>;
9
9
  }
10
10
 
11
11
  const {
12
12
  id,
13
- closeButton = true,
13
+ closeButton = 'default',
14
14
  closeButtonAtts,
15
15
  ...rest
16
16
  } = Astro.props;
@@ -22,14 +22,20 @@ const cssClass = attrs['class'] ?? '';
22
22
  delete attrs[a as keyof typeof attrs];
23
23
  });
24
24
 
25
+ const showCloseButton = closeButton !== false && closeButton !== 'false' && closeButton !== 'none';
26
+ const closeButtonCssClassList = ['evo-modal-close', 'evo-modal-action-hide'];
27
+ if (showCloseButton) {
28
+ closeButtonCssClassList.push(`evo-modal-theme-${closeButton}`)
29
+ }
30
+
25
31
  ---
26
- <div id={id} class:list={['evo-modal', cssClass]} {...attrs}>
27
- {closeButton && <button class="evo-modal-close evo-modal-action-hide" {...closeButtonAtts}><span class="evo-modal-x"><slot name="close">X</slot></span></button>}
32
+ <evo-modal id={id} class:list={['evo-modal', cssClass]} {...attrs}>
33
+ {showCloseButton && <button class:list={closeButtonCssClassList} {...closeButtonAtts}><span class="evo-modal-x"><slot name="close">X</slot></span></button>}
28
34
  <slot name="outer" />
29
35
  <div class="evo-modal-wrapper">
30
36
  <slot />
31
37
  </div>
32
- </div>
38
+ </evo-modal>
33
39
 
34
40
  <script>
35
41
  import './Modal';
@@ -8,6 +8,7 @@
8
8
  --evo-modal-height: 450px;
9
9
  --evo-modal-animation-duration: 300ms;
10
10
  --evo-modal-z-index: 99;
11
+ --evo-modal-overlay-blur: 2px;
11
12
  }
12
13
 
13
14
  .evo-modal-overlay {
@@ -18,11 +19,16 @@
18
19
  opacity: 0;
19
20
  width: 100%;
20
21
  height: 100%;
22
+ backdrop-filter: blur(var(--evo-modal-overlay-blur));
21
23
  background-color: rgba(0,0,0,0.66);
22
24
  z-index: calc(var(--evo-modal-z-index) - 1);
25
+ animation-duration: var(--evo-modal-animation-duration);
26
+ animation-iteration-count: 1;
27
+ animation-timing-function: linear;
28
+ animation-fill-mode: forwards;
23
29
  }
24
30
 
25
- .evo-modal {
31
+ evo-modal {
26
32
  position: var(--evo-modal-position);
27
33
  left: calc((var(--evo-modal-viewport-width) - var(--evo-modal-width)) / 2);
28
34
  top: calc((var(--evo-modal-viewport-height) - var(--evo-modal-height)) / 2);
@@ -36,6 +42,10 @@
36
42
  background-color: #ffffff;
37
43
  z-index: var(--evo-modal-z-index);
38
44
  box-sizing: border-box;
45
+ animation-duration: var(--evo-modal-animation-duration);
46
+ animation-iteration-count: 1;
47
+ animation-timing-function: linear;
48
+ animation-fill-mode: forwards;
39
49
 
40
50
  .evo-modal-close {
41
51
  /* the button click area is larger than the visible button */
@@ -50,37 +60,39 @@
50
60
  z-index: var(--evo-modal-z-index);
51
61
  box-sizing: border-box;
52
62
 
53
- .evo-modal-x {
54
- position: absolute;
55
- right: 8px;
56
- top: 8px;
57
- display: block;
58
- width: 24px;
59
- height: 24px;
60
- background-color: #990000;
61
- border: none;
62
- border-radius: 50%;
63
- text-align: left;
64
- text-indent: -9999px;
65
- transform: rotate(45deg);
66
-
67
- &::before,
68
- &::after {
69
- content: "";
63
+ &.evo-modal-theme-default {
64
+ .evo-modal-x {
70
65
  position: absolute;
71
- background-color: #ffffff;
72
- }
73
- &::before {
74
- left: 5px;
75
- top: 11px;
76
- width: 14px;
77
- height: 2px;
78
- }
79
- &::after {
80
- left: 11px;
81
- top: 5px;
82
- width: 2px;
83
- height: 14px;
66
+ right: 8px;
67
+ top: 8px;
68
+ display: block;
69
+ width: 24px;
70
+ height: 24px;
71
+ background-color: #990000;
72
+ border: none;
73
+ border-radius: 50%;
74
+ text-align: left;
75
+ text-indent: -9999px;
76
+ transform: rotate(45deg);
77
+
78
+ &::before,
79
+ &::after {
80
+ content: "";
81
+ position: absolute;
82
+ background-color: #ffffff;
83
+ }
84
+ &::before {
85
+ left: 5px;
86
+ top: 11px;
87
+ width: 14px;
88
+ height: 2px;
89
+ }
90
+ &::after {
91
+ left: 11px;
92
+ top: 5px;
93
+ width: 2px;
94
+ height: 14px;
95
+ }
84
96
  }
85
97
  }
86
98
  }
@@ -101,29 +113,27 @@
101
113
  }
102
114
  }
103
115
 
116
+ .evo-modal-visible {
117
+ display: block;
118
+ }
119
+
104
120
  .evo-modal-hide-none {
105
121
  display: none;
106
122
  opacity: 0;
107
123
  }
108
124
  .evo-modal-hide-fade {
109
- display: block;
125
+ /* display: block; */
110
126
  opacity: 0;
111
127
  animation-name: evo_modal_hide;
112
- animation-duration: var(--evo-modal-animation-duration);
113
- animation-iteration-count: 1;
114
- animation-timing-function: linear;
115
128
  }
116
129
  .evo-modal-show-none {
117
130
  display: block;
118
131
  opacity: 1;
119
132
  }
120
133
  .evo-modal-show-fade {
121
- display: block;
134
+ /* display: block; */
122
135
  opacity: 1;
123
136
  animation-name: evo_modal_show;
124
- animation-duration: var(--evo-modal-animation-duration);
125
- animation-iteration-count: 1;
126
- animation-timing-function: linear;
127
137
  }
128
138
 
129
139
  @keyframes evo_modal_show {