@studiometa/ui 0.2.4 → 0.2.7
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/atoms/Button/Button.twig +68 -0
- package/atoms/Button/StyledButton.twig +47 -0
- package/atoms/Cursor/Cursor.twig +28 -0
- package/atoms/Figure/Figure.cjs +12 -3
- package/atoms/Figure/Figure.d.ts +18 -0
- package/atoms/Figure/Figure.js +1 -1
- package/atoms/Figure/Figure.twig +120 -0
- package/atoms/Figure/FigureTwicPics.cjs +72 -0
- package/atoms/Figure/FigureTwicPics.d.ts +48 -0
- package/atoms/Figure/FigureTwicPics.js +1 -0
- package/atoms/Figure/index.cjs +31 -0
- package/atoms/Figure/index.d.ts +2 -0
- package/atoms/Figure/index.js +1 -0
- package/atoms/Icon/Icon.twig +13 -0
- package/atoms/LargeText/LargeText.twig +49 -0
- package/atoms/ScrollAnimation/AbstractScrollAnimation.cjs +126 -0
- package/atoms/ScrollAnimation/AbstractScrollAnimation.d.ts +133 -0
- package/atoms/ScrollAnimation/AbstractScrollAnimation.js +1 -0
- package/atoms/ScrollAnimation/ScrollAnimation.cjs +51 -0
- package/atoms/ScrollAnimation/ScrollAnimation.d.ts +55 -0
- package/atoms/ScrollAnimation/ScrollAnimation.js +1 -0
- package/atoms/ScrollAnimation/ScrollAnimationChild.cjs +51 -0
- package/atoms/ScrollAnimation/ScrollAnimationChild.d.ts +13 -0
- package/atoms/ScrollAnimation/ScrollAnimationChild.js +1 -0
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.cjs +41 -0
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.d.ts +6 -0
- package/atoms/ScrollAnimation/ScrollAnimationChildWithEase.js +1 -0
- package/atoms/ScrollAnimation/ScrollAnimationParent.cjs +48 -0
- package/atoms/ScrollAnimation/ScrollAnimationParent.d.ts +35 -0
- package/atoms/ScrollAnimation/ScrollAnimationParent.js +1 -0
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.cjs +41 -0
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.d.ts +6 -0
- package/atoms/ScrollAnimation/ScrollAnimationWithEase.js +1 -0
- package/atoms/ScrollAnimation/animationScrollWithEase.cjs +70 -0
- package/atoms/ScrollAnimation/animationScrollWithEase.d.ts +11 -0
- package/atoms/ScrollAnimation/animationScrollWithEase.js +1 -0
- package/atoms/ScrollAnimation/index.cjs +41 -0
- package/atoms/ScrollAnimation/index.d.ts +7 -0
- package/atoms/ScrollAnimation/index.js +1 -0
- package/atoms/index.cjs +2 -2
- package/atoms/index.d.ts +2 -1
- package/atoms/index.js +1 -1
- package/index.cjs +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -1
- package/molecules/Accordion/Accordion.twig +54 -0
- package/molecules/Modal/Modal.twig +108 -0
- package/molecules/Modal/StyledModal.twig +39 -0
- package/molecules/Panel/Panel.twig +73 -0
- package/molecules/Panel/StyledPanel.twig +28 -0
- package/molecules/Slider/Slider.cjs +12 -4
- package/molecules/Slider/Slider.d.ts +11 -0
- package/molecules/Slider/Slider.js +1 -1
- package/molecules/Slider/SliderItem.cjs +5 -4
- package/molecules/Slider/SliderItem.d.ts +5 -0
- package/molecules/Slider/SliderItem.js +1 -1
- package/molecules/Sticky/Sticky.twig +31 -0
- package/molecules/Tabs/Tabs.twig +20 -0
- package/organisms/Frame/Frame.cjs +40 -1
- package/organisms/Frame/Frame.d.ts +34 -1
- package/organisms/Frame/Frame.js +1 -1
- package/organisms/Frame/FrameTarget.cjs +3 -3
- package/organisms/Frame/FrameTarget.js +1 -1
- package/organisms/ImageGrid/ImageGrid.twig +42 -0
- package/package.json +2 -2
package/organisms/Frame/Frame.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Base as
|
|
1
|
+
import{Base as m}from"@studiometa/js-toolkit";import{nextFrame as c,historyPush as f}from"@studiometa/js-toolkit/utils";import p from"./FrameAnchor.js";import g from"./FrameForm.js";import F from"./FrameTarget.js";function u(){return{left:window.pageXOffset,top:window.pageYOffset}}const s=new Map;class a extends m{static config={name:"Frame",emits:["before-fetch","after-fetch","before-leave","after-leave","before-content","after-content","before-enter","after-enter"],log:!0,components:{FrameAnchor:p,FrameForm:g,FrameTarget:F,Frame:a},options:{history:Boolean}};get id(){return this.$el.id}getDirectChild(e){return this.$children[e]?this.$children.Frame?this.$children[e].filter(t=>this.$children.Frame.every(r=>r.$children[e]?!r.$children[e].includes(t):!0)):this.$children[e]:[]}get directChildFrameAnchor(){return this.getDirectChild("FrameAnchor")}get directChildFrameForm(){return this.getDirectChild("form")}get directChildFrameTarget(){return this.getDirectChild("FrameTarget")}mounted(){this.$options.history&&window.addEventListener("popstate",this)}destroyed(){window.removeEventListener("popstate",this)}handleEvent(e){e.type==="popstate"&&this.onWindowPopstate(e),e.type==="beforeunload"&&this.onWindowUnload()}onWindowUnload(){const{history:e}=window;!e.state||e.replaceState({...e.state,scroll:u()},"")}onWindowPopstate(e){this.goTo(window.location.href,e.state)}onFrameAnchorFrameClick(e,t){if(!this.directChildFrameAnchor.includes(this.$children.FrameAnchor[t]))return;this.$log("onAFrameClick",e,t),e.preventDefault();const r=this.$children.FrameAnchor[t];r.href!==window.location.href&&this.goTo(r.href)}onFrameFormFrameSubmit(e,t){if(!this.directChildFrameForm.includes(this.$children.FrameForm[t]))return;this.$log("onFrameFormFrameSubmit",e),e.preventDefault();const r=this.$children.FrameForm[t];this.goTo(r.action)}parseHTML(e=""){return new DOMParser().parseFromString(e,"text/html")}async goTo(e,t=null){this.$log("goTo",e);const r=new URL(e);if(r.origin!==window.location.origin)throw new Error("Cross origin request are not allowed.");this.$emit("before-fetch",e);const i=await this.fetch(e),n=this.parseHTML(i),l=n.querySelector(`#${this.id}`),h=new a(l);h.$children.registerAll(),this.$emit("after-fetch",e,i),this.$emit("before-leave"),await Promise.all(this.directChildFrameTarget.map(o=>o.leave())),this.$emit("after-leave"),this.$emit("before-content"),this.directChildFrameTarget.map((o,d)=>o.updateContent(h.directChildFrameTarget[d])),this.$options.history&&(document.title=n.title,f({path:r.pathname,search:r.searchParams})),t&&(document.scrollingElement.scrollTop=t.top,document.scrollingElement.scrollLeft=t.left),await c(),this.$root.$update(),await c(),this.$emit("after-content"),this.$emit("before-enter"),await Promise.all(this.directChildFrameTarget.map(o=>o.enter())),this.$emit("after-enter")}async fetch(e){const t=s.get(e);if(t)return t.status==="pending"?t.promise:t.content;const r=fetch(e);try{s.set(e,{promise:r,status:"pending",content:void 0});const i=await r.then(n=>n.text());return s.set(e,{promise:r,status:"resolved",content:i}),i}catch(i){return s.set(e,{promise:r,status:"error",content:i}),i}}}export{a as default};
|
|
@@ -40,19 +40,19 @@ var _FrameTarget = class extends import_primitives.Transition {
|
|
|
40
40
|
}
|
|
41
41
|
async enter() {
|
|
42
42
|
this.$log("enter");
|
|
43
|
-
const { enterFrom: from, enterActive: active, enterTo: to, leaveTo } = this.$options;
|
|
43
|
+
const { enterFrom: from, enterActive: active, enterTo: to, leaveTo, enterKeep } = this.$options;
|
|
44
44
|
const transitionStyles = { from, active, to };
|
|
45
45
|
switch (this.$options.mode) {
|
|
46
46
|
case "append":
|
|
47
47
|
case "prepend":
|
|
48
48
|
await Promise.all(Array.from(this.$el.children).filter((child) => from.split(" ").every((className) => child.classList.contains(className))).map((child) => {
|
|
49
|
-
return (0, import_utils.transition)(child, transitionStyles);
|
|
49
|
+
return (0, import_utils.transition)(child, transitionStyles, enterKeep && "keep");
|
|
50
50
|
}));
|
|
51
51
|
break;
|
|
52
52
|
case "replace":
|
|
53
53
|
default:
|
|
54
54
|
transitionStyles.from = Array.from(new Set([from, leaveTo].flat())).join(" ");
|
|
55
|
-
await (0, import_utils.transition)(this.$el, transitionStyles);
|
|
55
|
+
await (0, import_utils.transition)(this.$el, transitionStyles, enterKeep && "keep");
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
updateContent(newTarget) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{transition as
|
|
1
|
+
import{transition as a}from"@studiometa/js-toolkit/utils";import{Transition as r}from"../../primitives/index.js";class o extends r{static config={...r.config,name:"FrameTarget",log:!0,options:{...r.config.options,mode:{type:String,default:"replace"},id:String}};static __INSERT_MODES={prepend:"afterbegin",append:"beforeend"};get $options(){const e=super.$options;return e.leaveKeep=!0,e}get id(){return this.$options.id??this.$el.id}async enter(){this.$log("enter");const{enterFrom:e,enterActive:t,enterTo:p,leaveTo:l,enterKeep:s}=this.$options,i={from:e,active:t,to:p};switch(this.$options.mode){case"append":case"prepend":await Promise.all(Array.from(this.$el.children).filter(n=>e.split(" ").every(c=>n.classList.contains(c))).map(n=>a(n,i,s&&"keep")));break;case"replace":default:i.from=Array.from(new Set([e,l].flat())).join(" "),await a(this.$el,i,s&&"keep")}}updateContent(e){switch(this.$options.mode){case"prepend":case"append":Array.from(e.$el.children).forEach(t=>{t.classList.add(...this.$options.enterFrom.split(" "))}),this.$el.insertAdjacentHTML(o.__INSERT_MODES[this.$options.mode],e.$el.innerHTML);break;case"replace":default:this.$el.innerHTML=e.$el.innerHTML;break}}}export{o as default};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{#
|
|
2
|
+
/**
|
|
3
|
+
* @file
|
|
4
|
+
* Image Grid.
|
|
5
|
+
*
|
|
6
|
+
* @param array<Figure> $images
|
|
7
|
+
* List of images to display. See Figure.twig for the composition of each image.
|
|
8
|
+
* @param array $attr
|
|
9
|
+
* Custom attributes for the root element.
|
|
10
|
+
* @param array $inner_attr
|
|
11
|
+
* Custom attributes for the inner element.
|
|
12
|
+
* @param array $image_attr
|
|
13
|
+
* Custom attributes for the images' elements.
|
|
14
|
+
*/
|
|
15
|
+
#}
|
|
16
|
+
|
|
17
|
+
{% set attributes = merge_html_attributes(attr ?? null, { class: 'image-grid' }) %}
|
|
18
|
+
{% set inner_attributes =
|
|
19
|
+
merge_html_attributes(inner_attr ?? null, { class: 'image-grid__inner s:grid grid-cols-12 gap-10' })
|
|
20
|
+
%}
|
|
21
|
+
|
|
22
|
+
<div {{ html_attributes(attributes) }}>
|
|
23
|
+
<div {{ html_attributes(inner_attributes) }}>
|
|
24
|
+
{% for image in images %}
|
|
25
|
+
{% set modulo = loop.index % 5 %}
|
|
26
|
+
{% set image_attributes = merge_html_attributes(image_attr ?? null, {
|
|
27
|
+
class: 'image-grid__img'
|
|
28
|
+
}, {
|
|
29
|
+
class: {
|
|
30
|
+
's:col-span-7': modulo == 1 or modulo == 4,
|
|
31
|
+
's:col-span-5 mt-10': modulo == 2,
|
|
32
|
+
's:col-span-5 mt-10 clear-m-left': modulo == 3 and not loop.last,
|
|
33
|
+
's:col-start-2 s:col-end-11': modulo == 0 or (modulo in [0,3] and loop.last),
|
|
34
|
+
's:col-start-2 s:col-end-13': loop.first and loop.last
|
|
35
|
+
}
|
|
36
|
+
}) %}
|
|
37
|
+
<div {{ html_attributes(image_attributes) }}>
|
|
38
|
+
{% include '@ui/atoms/Figure/Figure.twig' with image only %}
|
|
39
|
+
</div>
|
|
40
|
+
{% endfor %}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiometa/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "A set of opiniated, unstyled and accessible components",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/studiometa/ui#readme",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@studiometa/js-toolkit": "^2.0.0
|
|
32
|
+
"@studiometa/js-toolkit": "^2.0.0",
|
|
33
33
|
"deepmerge": "^4.2.2"
|
|
34
34
|
}
|
|
35
35
|
}
|