@1024pix/epreuves-components 0.1.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,42 @@
1
+ import { d as i, r as l, c as n, o as a, n as p, a as t, b as c, F as u, e as f, f as m, _ as g, g as _ } from "../_plugin-vue_export-helper-CG_vnhyz.js";
2
+ const v = { class: "card-inner" }, y = /* @__PURE__ */ i({
3
+ __name: "CarteARetourner",
4
+ props: {
5
+ card: {}
6
+ },
7
+ setup(d) {
8
+ const e = l(!1);
9
+ return (s, r) => (a(), n("div", {
10
+ class: p(["card", { flipped: e.value }]),
11
+ onClick: r[0] || (r[0] = (o) => e.value = !e.value)
12
+ }, [
13
+ t("div", v, [
14
+ t("div", {
15
+ class: "card-face card-front",
16
+ style: c({ backgroundImage: `url('${s.card.frontImageUrl}')` })
17
+ }, null, 4),
18
+ t("div", {
19
+ class: "card-face card-back",
20
+ style: c({ backgroundImage: `url('${s.card.backImageUrl}')` })
21
+ }, null, 4)
22
+ ])
23
+ ], 2));
24
+ }
25
+ }), b = /* @__PURE__ */ i({
26
+ __name: "CartesARetourner.ce",
27
+ props: {
28
+ props: { type: Object }
29
+ },
30
+ setup(d) {
31
+ return (e, s) => (a(), n("div", {
32
+ class: "container",
33
+ style: c({ "--cards-per-line": e.props.cardsPerLine })
34
+ }, [
35
+ (a(!0), n(u, null, f(e.props.cards, (r, o) => (a(), m(y, {
36
+ key: o,
37
+ card: r
38
+ }, null, 8, ["card"]))), 128))
39
+ ], 4));
40
+ }
41
+ }), k = ".container{display:grid;grid-template-columns:repeat(var(--cards-per-line),1fr);gap:20px;justify-items:center}.card{width:150px;height:150px;perspective:1000px;cursor:pointer}.card-inner{width:100%;height:100%;position:relative;transform-style:preserve-3d;transition:transform .6s}.card.flipped .card-inner{transform:rotateY(180deg)}.card-face{width:100%;height:100%;position:absolute;backface-visibility:hidden;display:flex;justify-content:center;align-items:center;font-size:24px;border-radius:10px;background-size:cover}.card-back{transform:rotateY(180deg)}", h = /* @__PURE__ */ g(b, [["styles", [k]]]);
42
+ window.customElements.define("cartes-a-retourner", _(h));
@@ -0,0 +1,92 @@
1
+ import { d as b, r as _, w as y, c as h, o as r, h as g, i as p, n as v, a as k, m as q, t as w, j as m, s as $, F as P, e as B, f as N, _ as j, g as z } from "../_plugin-vue_export-helper-CG_vnhyz.js";
2
+ function L(o, n = E) {
3
+ const i = [...o];
4
+ for (let a = i.length - 1; a > 0; a--) {
5
+ const e = n() % (a + 1);
6
+ [i[a], i[e]] = [i[e], i[a]];
7
+ }
8
+ return i;
9
+ }
10
+ function E() {
11
+ return Math.floor(Math.random() * 2 ** 32);
12
+ }
13
+ const M = ["aria-checked", "tabindex"], Q = { key: 0 }, S = /* @__PURE__ */ b({
14
+ __name: "QCUChoice",
15
+ props: {
16
+ choice: {},
17
+ maxChoicesPerLine: {},
18
+ imageClass: {},
19
+ nameClass: {},
20
+ checked: { type: Boolean },
21
+ focusable: { type: Boolean }
22
+ },
23
+ emits: ["check", "checkNext", "checkPrevious"],
24
+ setup(o) {
25
+ const n = o, i = _();
26
+ y(() => {
27
+ var e;
28
+ n.checked && ((e = i.value) == null || e.focus());
29
+ });
30
+ const a = `qcu-image-choice-${(n.choice.response ?? n.choice.name).replace(/[^\w\-_:.]/g, "")}`;
31
+ return (e, s) => (r(), h("li", {
32
+ ref_key: "el",
33
+ ref: i,
34
+ role: "radio",
35
+ class: v(["qcu-image__choice", `qcu-image__choice--max${n.maxChoicesPerLine}`]),
36
+ "aria-labelledby": a,
37
+ "aria-checked": e.checked,
38
+ tabindex: e.focusable ? 0 : -1,
39
+ onClick: s[0] || (s[0] = p((c) => e.$emit("check"), ["stop"])),
40
+ onKeydown: [
41
+ s[1] || (s[1] = g(p((c) => e.$emit("check"), ["stop", "prevent"]), ["enter", "space"])),
42
+ s[2] || (s[2] = g(p((c) => e.$emit("checkPrevious"), ["stop", "prevent"]), ["up", "left"])),
43
+ s[3] || (s[3] = g(p((c) => e.$emit("checkNext"), ["stop", "prevent"]), ["down", "right"]))
44
+ ]
45
+ }, [
46
+ e.choice.image ? (r(), h("figure", Q, [
47
+ k("img", q(e.choice.image, {
48
+ class: e.imageClass,
49
+ alt: ""
50
+ }), null, 16),
51
+ k("figcaption", {
52
+ class: v(e.nameClass),
53
+ id: a
54
+ }, w(e.choice.name), 3)
55
+ ])) : (r(), h("span", {
56
+ key: 1,
57
+ id: a
58
+ }, w(e.choice.name), 1))
59
+ ], 42, M));
60
+ }
61
+ }), U = ["aria-label"], F = /* @__PURE__ */ b({
62
+ __name: "QCUImage.ce",
63
+ props: {
64
+ props: { type: Object }
65
+ },
66
+ emits: ["answer"],
67
+ setup(o, { emit: n }) {
68
+ const i = n, a = m(() => o.props.maxChoicesPerLine ?? 5), e = m(() => o.props.hideChoicesName ? "sr-only" : ""), s = m(() => o.props.imageChoicesSize ?? "icon"), c = m(() => o.props.orderChoices ? o.props.choices : L(o.props.choices)), t = $(), C = m(() => t.value ?? c.value[0]);
69
+ function d(l) {
70
+ l === -1 ? t.value = c.value[c.value.length - 1] : l === c.value.length ? t.value = c.value[0] : t.value = c.value[l], i("answer", t.value.response ?? t.value.name);
71
+ }
72
+ return (l, O) => (r(), h("ul", {
73
+ role: "radiogroup",
74
+ class: "qcu-image",
75
+ "aria-label": l.props.name
76
+ }, [
77
+ (r(!0), h(P, null, B(c.value, (f, u) => (r(), N(S, {
78
+ choice: f,
79
+ "max-choices-per-line": a.value,
80
+ key: u,
81
+ "name-class": e.value,
82
+ "image-class": s.value,
83
+ checked: f === t.value,
84
+ focusable: f === C.value,
85
+ onCheck: (x) => d(u),
86
+ onCheckNext: (x) => d(u + 1),
87
+ onCheckPrevious: (x) => d(u - 1)
88
+ }, null, 8, ["choice", "max-choices-per-line", "name-class", "image-class", "checked", "focusable", "onCheck", "onCheckNext", "onCheckPrevious"]))), 128))
89
+ ], 8, U));
90
+ }
91
+ }), I = '*{box-sizing:border-box}ul,li{padding:0;margin:0}li{list-style:none}.qcu-image{display:flex;width:100%;flex-wrap:wrap;justify-content:space-around;font-size:110%;font-family:Open Sans,Arial,sans-serif}.qcu-image__choice{display:flex;position:relative;flex-direction:column;align-items:center;justify-content:center;margin:1em;border:solid 2px #c1c7d0;border-radius:10px;background:#fff;width:calc(20% - 2em);min-width:120px}.qcu-image__choice--max4{width:calc(25% - 2em);min-width:175px}.qcu-image__choice--max3{width:calc(33% - 2em)}.qcu-image__choice--max2{width:calc(50% - 2em);min-width:300px}.qcu-image__choice--max1{width:calc(100% - 4em);min-width:300px}.qcu-image__choice:hover{cursor:pointer;box-shadow:0 3px 10px #0000001a;transform:scale(1.04);transition:transform ease-in .1s}.qcu-image__choice:focus{outline:none;box-shadow:5px 5px #ffbe00,-5px 5px #ffbe00,5px -5px #ffbe00,-5px -5px #ffbe00}.qcu-image__choice[aria-checked=true]{border-color:#3d68ff}.qcu-image__choice[aria-checked=true]:after{content:"";position:absolute;width:100%;height:100%;background:#3d68ff4d;border-radius:10px;z-index:3}.qcu-image__choice figure{width:100%;padding:0 10px;margin:3px;text-align:center}.qcu-image__choice figure img{max-width:100%;height:auto}.qcu-image__choice figure img.icon{max-height:100px;width:auto}.qcu-image__choice figure img.medium{max-width:50%;height:auto}.qcu-image__choice figure figcaption{margin:1ex}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}', K = /* @__PURE__ */ j(F, [["styles", [I]]]);
92
+ window.customElements.define("qcu-image", z(K));
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import "./components/qcu-image.js";
2
+ import "./components/cartes-a-retourner.js";
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@1024pix/epreuves-components",
3
+ "version": "0.1.0",
4
+ "description": "A collection of interactive components to be used in Pix challenges or modules",
5
+ "exports": {
6
+ ".": "./dist/index.js",
7
+ "./components/*": "./dist/components/*.js"
8
+ },
9
+ "files": [
10
+ "dist/"
11
+ ],
12
+ "scripts": {
13
+ "build": "(cd .. && npm run components:build)"
14
+ },
15
+ "author": "GIP Pix",
16
+ "license": "MIT",
17
+ "publishConfig": {
18
+ "access": "public"
19
+ }
20
+ }