@inizioevoke/astro-core 1.4.2 → 1.5.1

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,16 +1,18 @@
1
1
  {
2
2
  "name": "@inizioevoke/astro-core",
3
- "version": "1.4.2",
3
+ "version": "1.5.1",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
7
7
  "type": "module",
8
8
  "main": "./index.ts",
9
9
  "exports": {
10
- "./components": "./src/components/index.ts",
11
- "./components/Modal": "./src/components/Modal/index.ts",
12
- "./components/ScrollContainer": "./src/components/ScrollContainer/index.ts",
13
- "./integrations": "./src/integrations/index.ts"
10
+ ".": "./src/components/index.ts",
11
+ "./integrations": "./src/integrations/index.ts",
12
+ "./lib": "./src/lib/index.ts",
13
+ "./lib/FlipCard": "./src/components/FlipCard/index.ts",
14
+ "./lib/Modal": "./src/components/Modal/index.ts",
15
+ "./lib/ScrollContainer": "./src/components/ScrollContainer/index.ts"
14
16
  },
15
17
  "files": [
16
18
  "src",
@@ -0,0 +1,57 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+ import './FlipCard.css';
4
+ interface Props extends HTMLAttributes<'div'> {
5
+ width?: number;
6
+ height?: number;
7
+ perspective?: number;
8
+ }
9
+
10
+ const {
11
+ width,
12
+ height,
13
+ perspective,
14
+ ...rest
15
+ } = Astro.props;
16
+
17
+ const attrs = {...rest};
18
+
19
+ const style: string[] = [];
20
+ if (attrs.style) {
21
+ style.push(attrs.style as string);
22
+ }
23
+ if (width) {
24
+ style.push(`--width:${width}px`);
25
+ }
26
+ if (height) {
27
+ style.push(`--height:${height}px`);
28
+ }
29
+ if (perspective) {
30
+ style.push(`--perspective:${perspective}px`);
31
+ }
32
+
33
+ delete attrs.style;
34
+
35
+ // Both or default: <div slot="trigger">[content]</div>
36
+ const triggerSlot = Astro.slots.has('trigger') ? await Astro.slots.render('trigger') : undefined;
37
+ // Front: <div slot="front-trigger">[front content]</div>
38
+ const frontTriggerSlot = Astro.slots.has('front-trigger') ? await Astro.slots.render('front-trigger') : triggerSlot;
39
+ // Back: <div slot="back-trigger">[back content]</div>
40
+ const backTriggerSlot = Astro.slots.has('back-trigger') ? await Astro.slots.render('back-trigger') : triggerSlot;
41
+ ---
42
+ <evo-flip-card flipped="false" style={style.join(';')} {...attrs}>
43
+ <div class="evo-flip-card-wrapper">
44
+ <div class="evo-flip-card-front">
45
+ <button class="evo-flip-card-trigger">{frontTriggerSlot ?? <Fragment set:html={'&#8635;'} />}</button>
46
+ <slot name="front" />
47
+ </div>
48
+ <div class="evo-flip-card-back">
49
+ <button class="evo-flip-card-trigger">{backTriggerSlot ?? <Fragment set:html={'&#8635;'} />}</button>
50
+ <slot name="back" />
51
+ </div>
52
+ </div>
53
+ </evo-flip-card>
54
+
55
+ <script>
56
+ import './FlipCard';
57
+ </script>
@@ -0,0 +1,50 @@
1
+ evo-flip-card {
2
+ --evo-flip-card-width: 640px;
3
+ --evo-flip-card-height: 360px;
4
+ --evo-flip-card-duration: 0.6s;
5
+
6
+ display: block;
7
+ width: var(--evo-flip-card-width);
8
+ height: var(--evo-flip-card-height);
9
+ perspective: 1000px;
10
+
11
+ .evo-flip-card-wrapper {
12
+ position: relative;
13
+ width: 100%;
14
+ height: var(--evo-flip-card-height);
15
+ transition: transform var(--evo-flip-card-duration);
16
+ transform-style: preserve-3d;
17
+ transform-origin: center center;
18
+
19
+ .evo-flip-card-front,
20
+ .evo-flip-card-back {
21
+ position: absolute;
22
+ left: 0;
23
+ top: 0;
24
+ width: 100%;
25
+ height: var(--evo-flip-card-height);
26
+ -webkit-backface-visibility: hidden;
27
+ backface-visibility: hidden;
28
+ transform-style: preserve-3d;
29
+ transform: rotateY(0deg);
30
+ transform-origin: center center;
31
+
32
+ .evo-flip-card-trigger {
33
+ position: absolute;
34
+ top: 8px;
35
+ right: 8px;
36
+ cursor: pointer;
37
+ z-index: 99;
38
+ }
39
+ }
40
+ .evo-flip-card-back {
41
+ transform: rotateY(180deg);
42
+ }
43
+ }
44
+
45
+ &[flipped="true"] {
46
+ .evo-flip-card-wrapper {
47
+ transform: rotateY(180deg);
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,45 @@
1
+ const TAG_NAME = 'evo-flip-card';
2
+
3
+ export class EvoFlipCardElement extends HTMLElement {
4
+
5
+ static get observedAttributes(): string[] {
6
+ return ['flipped'];
7
+ }
8
+
9
+ #flipped: boolean = false;
10
+
11
+ constructor() {
12
+ super();
13
+ }
14
+
15
+ connectedCallback() {
16
+ [...this.querySelectorAll<HTMLButtonElement>('button.evo-flip-card-trigger')].forEach((btn) => {
17
+ btn.addEventListener('click', this.#handleTriggerClick.bind(this));
18
+ });
19
+ }
20
+
21
+ get flipped() {
22
+ return this.#flipped;
23
+ }
24
+ set flipped(value: boolean | string) {
25
+ this.#flipped = typeof value == 'string' ? value.toLowerCase() === 'true' : value === true;
26
+ this.setAttribute('flipped', this.#flipped.toString());
27
+ }
28
+
29
+ toggleFlipped() {
30
+ this.flipped = !this.flipped;
31
+ }
32
+ flipFront() {
33
+ this.flipped = false;
34
+ }
35
+ flipBack() {
36
+ this.flipped = true;
37
+ }
38
+
39
+ #handleTriggerClick() {
40
+ this.toggleFlipped();
41
+ }
42
+ }
43
+ if (!customElements.get(TAG_NAME)) {
44
+ customElements.define(TAG_NAME, EvoFlipCardElement);
45
+ }
@@ -0,0 +1 @@
1
+ export * from './FlipCard';
@@ -1,2 +1 @@
1
- export { default as Modal } from './Modal.astro';
2
1
  export * from './Modal';
@@ -1,2 +1 @@
1
- export { default as ScrollContainer } from './ScrollContainer.astro';
2
1
  export * from './ScrollContainer';
@@ -1,3 +1,4 @@
1
+ export { default as FlipCard } from './FlipCard/FlipCard.astro';
1
2
  export { default as Modal } from './Modal/Modal.astro';
2
3
  export { default as ModalOverlay } from './Modal/ModalOverlay.astro';
3
4
  export { default as ModalTrigger } from './Modal/ModalTrigger.astro';
@@ -0,0 +1,3 @@
1
+ export * as FlipCard from '../components/FlipCard/FlipCard';
2
+ export * as Modal from '../components/Modal/Modal';
3
+ export * as ScrollContainer from '../components/ScrollContainer/ScrollContainer';