@novely/dynamic-character 0.1.0 → 0.3.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/README.md CHANGED
@@ -68,7 +68,7 @@ const engine = novely({
68
68
  });
69
69
 
70
70
  const { showPicker: showPickerYou, showCharacter: showYou } = createPickerActions(engine.typeEssentials, clothingDataKyo, {
71
- character: 'You',
71
+ character: 'Ryan',
72
72
  defaultBase: 'default',
73
73
  defaultAttributes: {
74
74
  bottoms: 'jeans',
@@ -102,8 +102,7 @@ const { showPicker: showPickerYou, showCharacter: showYou } = createPickerAction
102
102
  variants: 'Options',
103
103
  slidesControl: 'Slides Control',
104
104
  prevSlide: 'Previous',
105
- nextSlide: "Next",
106
- apply: 'Apply',
105
+ nextSlide: 'Next',
107
106
  sumbit: 'Submit'
108
107
  }
109
108
  }
@@ -111,3 +110,7 @@ const { showPicker: showPickerYou, showCharacter: showYou } = createPickerAction
111
110
  });
112
111
 
113
112
  ```
113
+
114
+ ## Credits
115
+
116
+ This project uses [Slidy](https://github.com/Valexr/Slidy) for drag-scrolling functionality.
package/dist/index.css CHANGED
@@ -42,16 +42,13 @@
42
42
  display: none;
43
43
  }
44
44
  .ndc-tablist {
45
- width: 80%;
45
+ width: 100%;
46
46
  box-shadow: 0 0 0 .15rem var(--appearance-picker-tablist-border-color, #ffa6cd), var(--novely-px) var(--novely-px) .25rem var(--appearance-picker-box-shadow-color, #00000072);
47
47
  background-color: #ffc7df;
48
48
  border-radius: .875rem;
49
- justify-content: center;
50
- align-items: center;
49
+ flex-flow: row;
51
50
  gap: .5rem;
52
51
  margin-top: -2rem;
53
- margin-left: 10%;
54
- margin-right: 10%;
55
52
  padding: .25rem;
56
53
  transition: opacity .15s ease-in-out;
57
54
  display: flex;
@@ -62,10 +59,15 @@
62
59
  }
63
60
  .ndc-tab-button {
64
61
  cursor: pointer;
62
+ white-space: nowrap;
65
63
  background-color: #ffe9f3;
66
64
  border: none;
67
65
  border-radius: .5rem;
66
+ flex-shrink: 0;
67
+ place-content: center;
68
+ align-items: center;
68
69
  padding: .55rem .85rem;
70
+ display: flex;
69
71
  box-shadow: 0 0 0 .1rem #ffa6cd;
70
72
  }
71
73
  .ndc-tab-button:hover {
@@ -125,18 +127,12 @@
125
127
  height: 2.4rem;
126
128
  width: 2.4rem;
127
129
  }
128
- .ndc-button-nav-prev:not(:lang(ae, ar, arc, bcc, bqi, ckb, dv, fa, glk, he, ku, mzn, nqo, pnb, ps, sd, ug, ur, yi)) {
130
+ .ndc-button-nav-prev {
129
131
  left: .75rem;
130
132
  }
131
- .ndc-button-nav-prev:lang(ae, ar, arc, bcc, bqi, ckb, dv, fa, glk, he, ku, mzn, nqo, pnb, ps, sd, ug, ur, yi) {
132
- right: .75rem;
133
- }
134
- .ndc-button-nav-next:not(:lang(ae, ar, arc, bcc, bqi, ckb, dv, fa, glk, he, ku, mzn, nqo, pnb, ps, sd, ug, ur, yi)) {
133
+ .ndc-button-nav-next {
135
134
  right: .75rem;
136
135
  }
137
- .ndc-button-nav-next:lang(ae, ar, arc, bcc, bqi, ckb, dv, fa, glk, he, ku, mzn, nqo, pnb, ps, sd, ug, ur, yi) {
138
- left: .75rem;
139
- }
140
136
  .ndc-variant-name {
141
137
  color: #fff;
142
138
  text-align: center;
@@ -153,18 +149,16 @@
153
149
  }
154
150
  @media (max-aspect-ratio: .8) {
155
151
  .ndc-picker-root {
156
- width: calc(100% - 1rem);
152
+ width: calc(100% - .5rem);
157
153
  margin-bottom: 2.8rem;
158
- left: .5rem;
159
- right: .5rem;
154
+ left: .25rem;
155
+ right: .25rem;
160
156
  }
161
157
  .ndc-picker-root-collapsed {
162
158
  transform: translateY(calc(100% - 1.2rem));
163
159
  }
164
160
  .ndc-tablist {
165
- width: calc(100% - .5rem);
166
- margin-left: .25rem;
167
- margin-right: .25rem;
161
+ box-shadow: 0 0 0 .1rem var(--appearance-picker-tablist-border-color, #ffa6cd);
168
162
  }
169
163
  .ndc-slider,
170
164
  .ndc-slides {
@@ -188,11 +182,6 @@
188
182
  left: 0;
189
183
  right: 0;
190
184
  }
191
- .ndc-tablist {
192
- width: calc(100% - .5rem);
193
- margin-left: .25rem;
194
- margin-right: .25rem;
195
- }
196
185
  .ndc-slide {
197
186
  padding-left: 0;
198
187
  padding-right: 0;
@@ -223,7 +212,7 @@
223
212
  padding-bottom: 2rem;
224
213
  }
225
214
  .ndc-variant-name {
226
- margin-top: .6rem;
227
215
  font-size: 1.35rem;
216
+ top: .6rem;
228
217
  }
229
218
  }
package/dist/index.jsx CHANGED
@@ -1075,11 +1075,13 @@ function cleanChildren(parent, current, marker, replacement) {
1075
1075
  var RequestContext = Symbol();
1076
1076
 
1077
1077
  // src/picker.tsx
1078
+ import { slidy } from "@slidy/core";
1078
1079
  var _tmpl$ = /* @__PURE__ */ template(`<div class="ndc-picker-root"><button type="button" class="ndc-collapse-button"><svg data-icon fill="#fefefe" width="3rem" height="3rem" viewBox="0 0 256 256"><path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path></svg></button><div role="tablist" class="ndc-tablist">`);
1079
1080
  var _tmpl$2 = /* @__PURE__ */ template(`<button role="tab" class="ndc-tab-button">`);
1080
1081
  var _tmpl$3 = /* @__PURE__ */ template(`<div role="tabpanel" tabindex="0"><div role="region" class="ndc-slider"><div role="group" class="ndc-controls"><button type="button" class="ndc-button-nav ndc-button-nav-prev"><svg data-icon fill="currentColor" viewBox="0 0 256 256"><path d="M165.66 202.34a8 8 0 0 1-11.32 11.32l-80-80a8 8 0 0 1 0-11.32l80-80a8 8 0 0 1 11.32 11.32L91.31 128Z"></path></svg></button><button type="button" class="ndc-button-nav ndc-button-nav-next"><svg data-icon fill="currentColor" viewBox="0 0 256 256"><path d="m181.66 133.66-80 80a8 8 0 0 1-11.32-11.32L164.69 128 90.34 53.66a8 8 0 0 1 11.32-11.32l80 80a8 8 0 0 1 0 11.32Z"></path></svg></button></div><div class="ndc-slides" aria-live="polite">`);
1081
- var _tmpl$4 = /* @__PURE__ */ template(`<div role="group" class="ndc-slide"><p class="ndc-variant-name"></p><div class="ndc-control-buttons"><button type="button" class="button"></button><button type="button" class="button">`);
1082
+ var _tmpl$4 = /* @__PURE__ */ template(`<div role="group" class="ndc-slide"><p class="ndc-variant-name"></p><div class="ndc-control-buttons"><button type="button" class="button">`);
1082
1083
  var CHARACTER_STYLE_PICKER = Symbol();
1084
+ var PRELOADED_EMOTIONS = /* @__PURE__ */ new Set();
1083
1085
  var getTabs = ({
1084
1086
  base,
1085
1087
  attributes,
@@ -1163,6 +1165,9 @@ var showPicker = function() {
1163
1165
  _el$2.$$click = () => {
1164
1166
  setExpanded((value) => !value);
1165
1167
  };
1168
+ use((element2) => onCleanup(slidy(element2, {
1169
+ axis: "x"
1170
+ }).destroy), _el$4);
1166
1171
  insert(_el$4, createComponent(For, {
1167
1172
  each: tabs,
1168
1173
  children: (tab, i) => (() => {
@@ -1231,21 +1236,44 @@ var showPicker = function() {
1231
1236
  return;
1232
1237
  }
1233
1238
  const currentAppearance = untrack(appearance);
1234
- const currentVariant = variants[currentSlide()];
1239
+ const slide = currentSlide();
1240
+ const currentVariant = variants[slide];
1235
1241
  if (tab.type === "base") {
1236
- const emotion = getEmotionString({
1242
+ const emotion = getEmotionString(setAppearance({
1237
1243
  base: currentVariant,
1238
1244
  attributes: currentAppearance.attributes
1239
- });
1240
- character.emotion(emotion, false);
1245
+ }));
1246
+ character.emotion(emotion, true);
1247
+ PRELOADED_EMOTIONS.add(emotion);
1241
1248
  } else {
1242
- const emotion = getEmotionString({
1249
+ const emotion = getEmotionString(setAppearance({
1243
1250
  base: currentAppearance.base,
1244
1251
  attributes: {
1245
1252
  ...currentAppearance.attributes,
1246
1253
  [tab.value]: currentVariant
1247
1254
  }
1255
+ }));
1256
+ character.emotion(emotion, true);
1257
+ PRELOADED_EMOTIONS.add(emotion);
1258
+ }
1259
+ const nextIndex = slide < variants.length ? slide : 0;
1260
+ const prevIndex = slide > 0 ? slide - 1 : variants.length - 1;
1261
+ for (const index of [nextIndex, prevIndex]) {
1262
+ const emotion = tab.type === "base" ? getEmotionString({
1263
+ base: variants[index],
1264
+ attributes: currentAppearance.attributes
1265
+ }) : getEmotionString({
1266
+ base: currentAppearance.base,
1267
+ attributes: {
1268
+ ...currentAppearance.attributes,
1269
+ [tab.value]: variants[index]
1270
+ }
1248
1271
  });
1272
+ if (PRELOADED_EMOTIONS.has(emotion)) {
1273
+ continue;
1274
+ } else {
1275
+ PRELOADED_EMOTIONS.add(emotion);
1276
+ }
1249
1277
  character.emotion(emotion, false);
1250
1278
  }
1251
1279
  });
@@ -1279,32 +1307,14 @@ var showPicker = function() {
1279
1307
  children: (variant, i2) => {
1280
1308
  const titleId = createUniqueId();
1281
1309
  return (() => {
1282
- const _el$12 = _tmpl$4(), _el$13 = _el$12.firstChild, _el$14 = _el$13.nextSibling, _el$15 = _el$14.firstChild, _el$16 = _el$15.nextSibling;
1310
+ const _el$12 = _tmpl$4(), _el$13 = _el$12.firstChild, _el$14 = _el$13.nextSibling, _el$15 = _el$14.firstChild;
1283
1311
  setAttribute(_el$12, "aria-labelledby", titleId);
1284
1312
  setAttribute(_el$13, "id", titleId);
1285
1313
  insert(_el$13, () => translationGroup[variant]);
1286
1314
  _el$15.$$click = () => {
1287
- setAppearance((object) => {
1288
- if (tab.type === "attribute") {
1289
- return {
1290
- ...object,
1291
- attributes: {
1292
- ...object.attributes,
1293
- [tab.value]: variant
1294
- }
1295
- };
1296
- }
1297
- return {
1298
- ...object,
1299
- base: variant
1300
- };
1301
- });
1302
- };
1303
- insert(_el$15, () => translation.ui.apply);
1304
- _el$16.$$click = () => {
1305
1315
  resolve();
1306
1316
  };
1307
- insert(_el$16, () => translation.ui.sumbit);
1317
+ insert(_el$15, () => translation.ui.sumbit);
1308
1318
  createRenderEffect(() => _el$12.classList.toggle("ndc-slide-active", !!(i2() == currentSlide())));
1309
1319
  return _el$12;
1310
1320
  })();
@@ -0,0 +1,3 @@
1
+ import type { Accessor } from 'solid-js';
2
+ declare const createSlider: (node: Accessor<HTMLDivElement | undefined>) => void;
3
+ export { createSlider };
package/dist/types.d.ts CHANGED
@@ -103,7 +103,6 @@ type DynCharacterOptions<TE extends DefaultTypeEssentials, BaseKeys extends stri
103
103
  slidesControl: string;
104
104
  prevSlide: string;
105
105
  nextSlide: string;
106
- apply: string;
107
106
  sumbit: string;
108
107
  };
109
108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novely/dynamic-character",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,8 +15,9 @@
15
15
  "typescript": "^5.6.2"
16
16
  },
17
17
  "dependencies": {
18
+ "@slidy/core": "^3.8.0",
18
19
  "solid-js": "~1.9.3",
19
- "@novely/core": "0.46.2"
20
+ "@novely/core": "0.47.1"
20
21
  },
21
22
  "peerDependencies": {
22
23
  "@novely/core": "*",