ublo-lib 1.7.7 → 1.7.9

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.
@@ -116,7 +116,7 @@ const Carousel = ({
116
116
  const [dragging, setDragging] = React.useState(0);
117
117
  const editing = cmsMode === "editing";
118
118
  const draggingAllowed = !editing && allowDragOnDesktop;
119
- const targets = editing ? "section" : "section:not([data-hidden])";
119
+ const targets = "section[data-class]";
120
120
  const showNextArrow = current < count - 1;
121
121
  const showPrevArrow = current !== 0;
122
122
  const next = React.useCallback(e => {
@@ -0,0 +1,37 @@
1
+ import * as React from "react";
2
+ import css from "./detail.module.css";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { jsxs as _jsxs } from "react/jsx-runtime";
5
+ const Detail = ({
6
+ detail
7
+ }) => {
8
+ return _jsxs("div", {
9
+ className: css.container,
10
+ children: [_jsxs("div", {
11
+ className: css.header,
12
+ children: [_jsx("div", {
13
+ className: css.bar,
14
+ children: _jsx("div", {
15
+ className: css.name,
16
+ children: detail.nom
17
+ })
18
+ }), _jsx("div", {
19
+ className: css.univers,
20
+ children: detail.univers
21
+ })]
22
+ }), _jsxs("div", {
23
+ className: css.content,
24
+ children: [_jsx("div", {
25
+ dangerouslySetInnerHTML: {
26
+ __html: detail.description
27
+ }
28
+ }), detail.video && _jsx("iframe", {
29
+ src: `https://www.youtube-nocookie.com/embed/${detail.video}?rel=0`,
30
+ frameBorder: 0,
31
+ allowFullScreen: true,
32
+ title: "video"
33
+ })]
34
+ })]
35
+ });
36
+ };
37
+ export default Detail;
@@ -0,0 +1,154 @@
1
+ .container {
2
+ width: 100%;
3
+ max-width: 800px;
4
+ display: flex;
5
+ flex-direction: column;
6
+ margin: 0 auto;
7
+ }
8
+ .header {
9
+ display: flex;
10
+ flex-direction: column;
11
+ justify-content: center;
12
+ align-items: center;
13
+ width: 100%;
14
+ border-bottom: 1px solid var(--msem-color-mediumlight);
15
+ padding: 15px 0;
16
+ gap: 5px;
17
+ }
18
+ .imageOuter {
19
+ margin-top: -85px;
20
+ border-radius: 8px;
21
+ border: 2px solid var(--msem-color-mediumlight);
22
+ background-color: var(--msem-color-lightest);
23
+ width: 150px;
24
+ flex: 0 0 115px;
25
+ }
26
+ .imageOuter > img {
27
+ border-radius: 8px;
28
+ width: 150px;
29
+ height: 115px;
30
+ }
31
+ .bar {
32
+ flex: 1;
33
+ width: 100%;
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: center;
37
+ user-select: none;
38
+ }
39
+ .prev,
40
+ .next {
41
+ display: flex;
42
+ flex: 1 1 100%;
43
+ font-size: 12px;
44
+ align-items: center;
45
+ cursor: pointer;
46
+ color: var(--msem-color-dark);
47
+ }
48
+ .prev:hover,
49
+ .next:hover {
50
+ color: var(--msem-color-primary);
51
+ }
52
+ .prev {
53
+ justify-content: flex-start;
54
+ margin-right: auto;
55
+ }
56
+ .next {
57
+ justify-content: flex-end;
58
+ margin-left: auto;
59
+ }
60
+ .name {
61
+ font-weight: 700;
62
+ font-size: 30px;
63
+ color: var(--msem-color-darkest);
64
+ white-space: nowrap;
65
+ }
66
+ .univers {
67
+ color: var(--msem-color-primary);
68
+ font-size: 12px;
69
+ text-transform: uppercase;
70
+ font-weight: bold;
71
+ letter-spacing: 2px;
72
+ }
73
+ .content {
74
+ width: 100%;
75
+ overflow-y: scroll;
76
+ -ms-overflow-style: -ms-autohiding-scrollbar;
77
+ font-size: 14px;
78
+ }
79
+
80
+ .content > iframe {
81
+ width: 100%;
82
+ aspect-ratio: 16/9;
83
+ }
84
+ .content :global(.level_catchphrase) {
85
+ font-weight: bold;
86
+ padding-bottom: 10px;
87
+ }
88
+ .content p {
89
+ margin: 5px 0;
90
+ }
91
+ .content i {
92
+ font-size: 11px;
93
+ }
94
+ .content b {
95
+ display: inline-block;
96
+ padding-top: 10px;
97
+ }
98
+ .content em {
99
+ display: inline-block;
100
+ padding-top: 10px;
101
+ font-style: normal;
102
+ font-weight: bold;
103
+ }
104
+ .content li > em {
105
+ display: inline;
106
+ font-style: italic;
107
+ font-weight: normal;
108
+ }
109
+ .content ul {
110
+ padding: 0;
111
+ }
112
+ .content li {
113
+ background: url(level-bullet.svg) no-repeat 0 2px;
114
+ list-style-type: none;
115
+ line-height: 1.4;
116
+ padding: 0 0 10px 25px;
117
+ margin: 0;
118
+ }
119
+
120
+ @media (max-width: 400px) {
121
+ .overlay {
122
+ padding: 0;
123
+ }
124
+ .imageOuter {
125
+ margin-top: 0;
126
+ }
127
+ .dialog {
128
+ padding: 0;
129
+ border-radius: 0;
130
+ position: fixed;
131
+ top: 0;
132
+ left: 0;
133
+ right: 0;
134
+ bottom: 0;
135
+ max-height: 100%;
136
+ }
137
+ .close {
138
+ top: 10px;
139
+ right: 10px;
140
+ border-radius: 0;
141
+ }
142
+ .content {
143
+ width: auto;
144
+ padding: 0 20px;
145
+ }
146
+ .prev > span,
147
+ .next > span {
148
+ display: none;
149
+ }
150
+ .prev,
151
+ .next {
152
+ flex: 0 0 24px;
153
+ }
154
+ }
@@ -0,0 +1,2 @@
1
+ import Levels from "./levels";
2
+ export default Levels;
@@ -0,0 +1,4 @@
1
+ <svg width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M12.8 2.2A7.45 7.45 0 0 0 7.5 0c-2 0-3.89.78-5.3 2.2A7.45 7.45 0 0 0 0 7.5c0 2 .78 3.89 2.2 5.3A7.45 7.45 0 0 0 7.5 15c2 0 3.89-.78 5.3-2.2A7.45 7.45 0 0 0 15 7.5c0-2-.78-3.89-2.2-5.3ZM7.5 14.12A6.63 6.63 0 1 1 7.51.86a6.63 6.63 0 0 1-.01 13.26Z" fill="#00C553"/>
3
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M11.08 5.1a.44.44 0 0 0-.62 0L6.58 8.96 4.54 6.93a.44.44 0 0 0-.62.62l2.35 2.36a.44.44 0 0 0 .62 0l4.2-4.2a.44.44 0 0 0 0-.62Z" fill="#00C553"/>
4
+ </svg>
@@ -1,28 +1,84 @@
1
1
  import * as React from "react";
2
- import { useState, useEffect } from "react";
3
2
  import classnames from "classnames";
3
+ import Detail from "./detail";
4
4
  import { useUbloContext } from "ublo/with-ublo";
5
5
  import { fetchMenus, fetchZones } from "ublo/fetcher";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ const LEVELS = {
9
+ pioupiou: "ALPPIO",
10
+ blanchot: "ALPBLA",
11
+ sifflote: "ALPSIF",
12
+ garolou: "ALPGAR",
13
+ ourson: "ALPOUR",
14
+ flocon: "ALPFLO",
15
+ "1-star": "ALPET1",
16
+ "2-star": "ALPET2",
17
+ "3-star": "ALPET3",
18
+ "bronze-star": "ALPETB",
19
+ "silver-star": "ALPETA",
20
+ "gold-star": "ALPETO",
21
+ "1-ski": "ALPCL1",
22
+ "1-degree": "ALPCL2",
23
+ "2-degree": "ALPCL3",
24
+ "3-degree": "ALPCL4",
25
+ "goomie-rider": "SNOGOO",
26
+ "rookie-rider": "SNOROO",
27
+ "izzy-rider": "SNOIZZ",
28
+ "snowboard-discovery": "SNODEC",
29
+ "1-snowboard": "SNOSN1",
30
+ "2-snowboard": "SNOEN2",
31
+ "3-snowboard": "SNOEN3",
32
+ "snowboard-expert": "SNOEXP",
33
+ "ptit-freestyler": "SNOEN2",
34
+ "freestyler-inter": "SNOEN3",
35
+ freestyler: "FREE",
36
+ "freestyler-expert": "FREEXP",
37
+ "freestyler-pro": "FREPRO",
38
+ "ourson-nordic": "NOROUR",
39
+ "flocon-nordic": "NORFLO",
40
+ "1-star-nordic": "NORET1",
41
+ "2-star-nordic": "NORET2",
42
+ "3-star-nordic": "NORET3",
43
+ "bronze-star-nordic": "NORETB",
44
+ "gold-star-nordic": "NORETO",
45
+ "1-ski-nordic": "NORDEB",
46
+ "1-degree-nordic": "NORCL1",
47
+ "2-degree-nordic": "NORCL2",
48
+ "3-degree-nordic": "NORCL3",
49
+ "biathlon-level": "BIAAR"
50
+ };
51
+
8
52
  const LevelDetail = ({
9
- selectedLevel,
10
- contents
53
+ code
11
54
  }) => {
12
- const zoneId = `detail-${selectedLevel}`;
13
- const content = contents[zoneId];
14
- return _jsx("div", {
15
- className: "evaluate-level__detail",
16
- dangerouslySetInnerHTML: {
17
- __html: content
55
+ const {
56
+ lang
57
+ } = useUbloContext();
58
+ const [detail, setDetail] = React.useState();
59
+ const levelLang = lang === "fr" ? lang : "en";
60
+ React.useEffect(() => {
61
+ if (code) {
62
+ const getDetail = async () => {
63
+ const endpoint = `https://services.msem.tech/api/esf-wiki/${levelLang}/niveau/${code}`;
64
+ const result = await fetch(endpoint);
65
+ const json = await result.json();
66
+ setDetail(json);
67
+ };
68
+ getDetail();
18
69
  }
70
+ }, [code, levelLang]);
71
+ if (!detail) return null;
72
+ return _jsx(Detail, {
73
+ detail: detail
19
74
  });
20
75
  };
21
76
  const Level = ({
22
77
  level,
23
78
  contents,
24
79
  setSelectedLevel,
25
- selectedLevel
80
+ selectedLevel,
81
+ levelRef
26
82
  }) => {
27
83
  const {
28
84
  name,
@@ -30,14 +86,30 @@ const Level = ({
30
86
  } = level;
31
87
  const zoneId = `photo-${name}`;
32
88
  const content = contents[zoneId];
33
- const clicked = name => e => setSelectedLevel(name);
89
+ const clicked = name => e => {
90
+ if (levelRef.current) {
91
+ levelRef.current.scrollIntoView({
92
+ behaviour: "smooth",
93
+ block: "center",
94
+ inline: "center"
95
+ });
96
+ }
97
+ setSelectedLevel(name);
98
+ };
34
99
  const selected = name === selectedLevel;
35
100
  const levelClasses = classnames("evaluate-level__level", {
36
101
  "evaluate-level__level--selected": selected
37
102
  });
103
+ const hasContent = (name in LEVELS);
104
+ const styles = hasContent ? undefined : {
105
+ pointerEvents: "none",
106
+ touchAction: "none"
107
+ };
108
+ const onClick = hasContent ? clicked(name) : undefined;
38
109
  return _jsxs("div", {
39
110
  className: levelClasses,
40
- onClick: clicked(name),
111
+ style: styles,
112
+ onClick: onClick,
41
113
  children: [_jsx("h3", {
42
114
  className: "evaluate-level__level-title",
43
115
  children: title
@@ -55,7 +127,8 @@ const Levels = ({
55
127
  selectedActivity,
56
128
  selectedAge,
57
129
  setSelectedLevel,
58
- selectedLevel
130
+ selectedLevel,
131
+ levelRef
59
132
  }) => {
60
133
  return _jsxs("div", {
61
134
  className: "evaluate-level__levels",
@@ -65,13 +138,15 @@ const Levels = ({
65
138
  children: selectedAge.title
66
139
  })]
67
140
  }), _jsx("div", {
141
+ ref: levelRef,
68
142
  className: "evaluate-level__levels-outer",
69
143
  children: levels.map(level => {
70
144
  return _jsx(Level, {
71
145
  level: level,
72
146
  contents: contents,
73
147
  setSelectedLevel: setSelectedLevel,
74
- selectedLevel: selectedLevel
148
+ selectedLevel: selectedLevel,
149
+ levelRef: levelRef
75
150
  }, level.name);
76
151
  })
77
152
  })]
@@ -156,12 +231,13 @@ const EvaluateLevel = ({
156
231
  ubloApi,
157
232
  site
158
233
  } = config;
159
- const [activities, setActivities] = useState([]);
160
- const [levels, setLevels] = useState([]);
161
- const [contents, setContents] = useState({});
162
- const [selectedActivity, setSelectedActivity] = useState({});
163
- const [selectedAge, setSelectedAge] = useState({});
164
- const [selectedLevel, setSelectedLevel] = useState();
234
+ const levelRef = React.useRef(null);
235
+ const [activities, setActivities] = React.useState([]);
236
+ const [levels, setLevels] = React.useState([]);
237
+ const [contents, setContents] = React.useState({});
238
+ const [selectedActivity, setSelectedActivity] = React.useState({});
239
+ const [selectedAge, setSelectedAge] = React.useState({});
240
+ const [selectedLevel, setSelectedLevel] = React.useState();
165
241
  const activityChanged = activity => {
166
242
  const {
167
243
  name
@@ -177,7 +253,7 @@ const EvaluateLevel = ({
177
253
  setLevels([]);
178
254
  setSelectedLevel();
179
255
  };
180
- useEffect(() => {
256
+ React.useEffect(() => {
181
257
  const activitiesLoaded = activities.length > 0;
182
258
  if (menu !== undefined && activitiesLoaded) {
183
259
  const isFreestyle = menu.split("/").length - 1 === 2;
@@ -200,13 +276,13 @@ const EvaluateLevel = ({
200
276
  }
201
277
  }
202
278
  }, [activities, menu]);
203
- useEffect(() => {
279
+ React.useEffect(() => {
204
280
  const getActivities = async () => {
205
281
  setActivities(await fetchMenus(ubloApi, site, lang, "/levels", 2));
206
282
  };
207
283
  getActivities();
208
284
  }, [lang, site, ubloApi]);
209
- useEffect(() => {
285
+ React.useEffect(() => {
210
286
  const {
211
287
  menu
212
288
  } = selectedAge;
@@ -219,6 +295,7 @@ const EvaluateLevel = ({
219
295
  getLevels();
220
296
  }
221
297
  }, [lang, selectedAge, site, ubloApi]);
298
+ const selectedLevelCode = LEVELS[selectedLevel];
222
299
  return _jsxs("div", {
223
300
  className: "evaluate-level",
224
301
  children: [!menu && _jsx(Activities, {
@@ -233,10 +310,10 @@ const EvaluateLevel = ({
233
310
  selectedActivity: selectedActivity,
234
311
  selectedAge: selectedAge,
235
312
  setSelectedLevel: setSelectedLevel,
236
- selectedLevel: selectedLevel
237
- }), selectedLevel && _jsx(LevelDetail, {
238
313
  selectedLevel: selectedLevel,
239
- contents: contents
314
+ levelRef: levelRef
315
+ }), selectedLevel && _jsx(LevelDetail, {
316
+ code: selectedLevelCode
240
317
  })]
241
318
  });
242
319
  };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^2.1.0",
6
- "next": "^12.0.0",
6
+ "next": "^12.0.0 || ^13.0.0",
7
7
  "react": "^18.2.0",
8
8
  "react-dom": "^18.2.0",
9
9
  "ublo": "^2.0.0 || ^3.0.0"
@@ -45,9 +45,9 @@
45
45
  "scripts": {
46
46
  "clean": "rm -rf es",
47
47
  "build": "babel src -x '.js,.ts,.tsx' -d es && tsc",
48
- "postbuild": "cpx 'src/**/*.{json,css}' es",
48
+ "postbuild": "cpx 'src/**/*.{json,css,svg}' es",
49
49
  "prepublishOnly": "yarn clean && yarn build",
50
- "watch": "yarn clean && babel ./src -x '.js,.ts,.tsx' -d es -w & cpx './src/**/*.{json,css}' es -w",
50
+ "watch": "yarn clean && babel ./src -x '.js,.ts,.tsx' -d es -w & cpx './src/**/*.{json,css,svg}' es -w",
51
51
  "lint": "eslint 'src/**/*.{js, ts, tsx}'"
52
52
  },
53
53
  "packageManager": "yarn@1.22.18",