@novely/dynamic-character 0.3.0 → 0.4.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 +58 -37
- package/dist/actions.d.ts +7 -0
- package/dist/components/Picker.d.ts +19 -0
- package/dist/components/Slider.d.ts +12 -0
- package/dist/emotions.d.ts +1 -1
- package/dist/index.css +10 -26
- package/dist/index.d.ts +1 -6
- package/dist/index.jsx +332 -1293
- package/dist/picker.d.ts +2 -2
- package/dist/show.d.ts +2 -2
- package/dist/types.d.ts +65 -20
- package/dist/utils.d.ts +2 -1
- package/package.json +3 -3
- package/dist/slider.d.ts +0 -3
package/README.md
CHANGED
|
@@ -2,81 +2,89 @@
|
|
|
2
2
|
|
|
3
3
|
Will give a way to dynamically dress characters.
|
|
4
4
|
|
|
5
|
+
<div style="width: 100%; display: flex; justify-content: flex-start;">
|
|
6
|
+
<img alt="" src="https://raw.githubusercontent.com/yhdgms1/novely/main/packages/dynamic-character/preview.jpg" style="max-height: 20vh; max-width: 100vw;" />
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
5
11
|
```ts
|
|
6
12
|
import { generateEmotions } from '@novely/dynamic-character';
|
|
7
13
|
import '@novely/dynamic-character/dist/index.css';
|
|
8
14
|
```
|
|
9
15
|
|
|
10
16
|
```ts
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
17
|
+
import { novely, asset, EN } from '@novely/core';
|
|
18
|
+
|
|
19
|
+
import You_female from './assets/You-female-body.png';
|
|
20
|
+
import You_female_bottoms__shorts from './assets/You-female-bottoms--shorts.png'
|
|
21
|
+
import You_female_bottoms__jeans from './assets/You-female-bottoms--jeans.png'
|
|
22
|
+
import You_female_tops__pink_tshirt from './assets/You-female-tops--pink-t-shirt.png';
|
|
23
|
+
import You_female_tops__white_tshirt from './assets/You-female-tops--white-t-shirt.png';
|
|
16
24
|
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
25
|
+
import You_male from './assets/You-male-body.png';
|
|
26
|
+
import You_male_bottoms__shorts from './assets/You-male-bottoms--shorts.png'
|
|
27
|
+
import You_male_bottoms__jeans from './assets/You-male-bottoms--jeans.png'
|
|
28
|
+
import You_male_tops__pink_tshirt from './assets/You-male-tops--pink-t-shirt.png';
|
|
29
|
+
import You_male_tops__white_tshirt from './assets/You-male-tops--white-t-shirt.png';
|
|
22
30
|
|
|
23
|
-
const { emotions:
|
|
31
|
+
const { emotions: emotionsYou, createActions: createActionsYou } = generateEmotions({
|
|
24
32
|
base: {
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
male: asset(You_male),
|
|
34
|
+
female: asset(You_female)
|
|
27
35
|
},
|
|
28
36
|
attributes: {
|
|
29
37
|
bottoms: {
|
|
30
38
|
shorts: {
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
female: asset(You_female_bottoms__shorts),
|
|
40
|
+
male: asset(You_male_bottoms__shorts)
|
|
33
41
|
},
|
|
34
42
|
jeans: {
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
female: asset(You_female_bottoms__jeans),
|
|
44
|
+
male: asset(You_male_bottoms__jeans)
|
|
37
45
|
}
|
|
38
46
|
},
|
|
39
47
|
tops: {
|
|
40
48
|
pink: {
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
male: asset(You_male_tops__pink_tshirt),
|
|
50
|
+
female: asset(You_female_tops__pink_tshirt)
|
|
43
51
|
},
|
|
44
52
|
white: {
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
male: asset(You_male_tops__white_tshirt),
|
|
54
|
+
female: asset(You_female_tops__white_tshirt)
|
|
47
55
|
}
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
});
|
|
51
59
|
|
|
52
60
|
const engine = novely({
|
|
53
|
-
|
|
61
|
+
...,
|
|
54
62
|
translation: {
|
|
55
63
|
en: {
|
|
56
64
|
internal: EN
|
|
57
65
|
}
|
|
58
66
|
},
|
|
59
67
|
characters: {
|
|
60
|
-
|
|
68
|
+
You: {
|
|
61
69
|
name: {
|
|
62
|
-
en: '
|
|
70
|
+
en: 'You',
|
|
63
71
|
},
|
|
64
72
|
color: '#000000',
|
|
65
|
-
emotions:
|
|
73
|
+
emotions: emotionsYou
|
|
66
74
|
},
|
|
67
75
|
},
|
|
68
76
|
});
|
|
69
77
|
|
|
70
|
-
const
|
|
71
|
-
character: '
|
|
72
|
-
defaultBase: '
|
|
78
|
+
const dynamicYou = createActionsYou(engine, {
|
|
79
|
+
character: 'You',
|
|
80
|
+
defaultBase: 'male',
|
|
73
81
|
defaultAttributes: {
|
|
74
82
|
bottoms: 'jeans',
|
|
75
83
|
tops: 'white'
|
|
76
84
|
},
|
|
77
85
|
translation: {
|
|
78
86
|
en: {
|
|
79
|
-
|
|
87
|
+
title: {
|
|
80
88
|
base: 'Body',
|
|
81
89
|
attributes: {
|
|
82
90
|
bottoms: 'Bottoms',
|
|
@@ -84,8 +92,8 @@ const { showPicker: showPickerYou, showCharacter: showYou } = createPickerAction
|
|
|
84
92
|
}
|
|
85
93
|
},
|
|
86
94
|
base: {
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
male: 'Male',
|
|
96
|
+
female: 'Female'
|
|
89
97
|
},
|
|
90
98
|
attributes: {
|
|
91
99
|
bottoms: {
|
|
@@ -98,19 +106,32 @@ const { showPicker: showPickerYou, showCharacter: showYou } = createPickerAction
|
|
|
98
106
|
}
|
|
99
107
|
},
|
|
100
108
|
ui: {
|
|
101
|
-
tablist: 'Clothing Options',
|
|
102
109
|
variants: 'Options',
|
|
103
110
|
slidesControl: 'Slides Control',
|
|
104
111
|
prevSlide: 'Previous',
|
|
105
112
|
nextSlide: 'Next',
|
|
106
|
-
sumbit: 'Submit'
|
|
113
|
+
sumbit: 'Submit',
|
|
114
|
+
sumbit: 'Submit',
|
|
115
|
+
buy: 'Buy'
|
|
107
116
|
}
|
|
108
117
|
}
|
|
109
118
|
}
|
|
110
119
|
});
|
|
111
120
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
121
|
+
engine.script({
|
|
122
|
+
start: [
|
|
123
|
+
// Male or Female
|
|
124
|
+
dynamicYou.showBasePicker(),
|
|
125
|
+
// Jeans or Shorts
|
|
126
|
+
dynamicYou.showAttributePicker({ name: 'bottoms' }),
|
|
127
|
+
// Pink or White t-shirt
|
|
128
|
+
dynamicYou.showAttributePicker({ name: 'tops' }),
|
|
129
|
+
// Show the character
|
|
130
|
+
dynamicYou.showCharacter(),
|
|
131
|
+
// Admire the appearance :)
|
|
132
|
+
engine.action.say("You", "Mirror, Mirror on the Wall, Who’s the Fairest of Them All?"),
|
|
133
|
+
engine.action.end()
|
|
134
|
+
]
|
|
135
|
+
})
|
|
115
136
|
|
|
116
|
-
|
|
137
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EngineInstance, Attributes, ClothingData, AllOptions, ShowPickerOptionsAttribute, ShowPickerOptionsBase, DefaultTypeEssentials } from './types';
|
|
2
|
+
declare const createActions: (this: ClothingData<string, Attributes>, engine: EngineInstance, options: AllOptions<DefaultTypeEssentials, string, Attributes>) => {
|
|
3
|
+
showBasePicker: (options?: ShowPickerOptionsBase) => import("@novely/core").ValidAction;
|
|
4
|
+
showAttributePicker: (options: ShowPickerOptionsAttribute<Attributes>) => import("@novely/core").ValidAction;
|
|
5
|
+
showCharacter: () => import("@novely/core").ValidAction;
|
|
6
|
+
};
|
|
7
|
+
export { createActions };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Component, Setter } from 'solid-js';
|
|
2
|
+
import type { AllThis, EmotionObject } from '../types';
|
|
3
|
+
type PickerProps = {
|
|
4
|
+
title: string;
|
|
5
|
+
initialExpanded: boolean;
|
|
6
|
+
initialEmotion: EmotionObject;
|
|
7
|
+
slides: string[];
|
|
8
|
+
pricing: number[];
|
|
9
|
+
translationGroup: Record<string, string>;
|
|
10
|
+
translation: AllThis['options']['translation'][string];
|
|
11
|
+
getInitialSlideIndex: (appearance: EmotionObject) => number;
|
|
12
|
+
onIndexChange: (appearance: EmotionObject, setAppearance: Setter<EmotionObject>, slide: number) => void;
|
|
13
|
+
saveEmotion: (appearance: EmotionObject) => void;
|
|
14
|
+
sumbit: () => void;
|
|
15
|
+
buy: (variant: string) => Promise<boolean>;
|
|
16
|
+
isBought: (variant: string) => boolean;
|
|
17
|
+
};
|
|
18
|
+
declare const Picker: Component<PickerProps>;
|
|
19
|
+
export { Picker };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Accessor, Component, JSX } from 'solid-js';
|
|
2
|
+
import type { AllThis } from '../types';
|
|
3
|
+
type SliderProps = {
|
|
4
|
+
initialSlideIndex: number;
|
|
5
|
+
slides: string[];
|
|
6
|
+
expanded: boolean;
|
|
7
|
+
translation: AllThis['options']['translation'][string];
|
|
8
|
+
children: (slide: string, i: Accessor<number>) => JSX.Element;
|
|
9
|
+
onIndexChange: (currentIndex: number) => void;
|
|
10
|
+
};
|
|
11
|
+
declare const Slider: Component<SliderProps>;
|
|
12
|
+
export { Slider };
|
package/dist/emotions.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Attributes, EmotionsDefinition, EmotionsResult } from './types';
|
|
2
|
-
declare const generateEmotions: <BaseKeys extends string, Attribs extends Attributes<BaseKeys>>({ base, attributes, }: EmotionsDefinition<BaseKeys, Attribs>) => EmotionsResult<BaseKeys, Attribs>;
|
|
2
|
+
declare const generateEmotions: <BaseKeys extends string, Attribs extends Attributes<BaseKeys>>({ base, attributes, pricing, }: EmotionsDefinition<BaseKeys, Attribs>) => EmotionsResult<BaseKeys, Attribs>;
|
|
3
3
|
export { generateEmotions };
|
package/dist/index.css
CHANGED
|
@@ -41,39 +41,23 @@
|
|
|
41
41
|
.ndc-tabpanel-hidden {
|
|
42
42
|
display: none;
|
|
43
43
|
}
|
|
44
|
-
.ndc-
|
|
45
|
-
|
|
44
|
+
.ndc-heading {
|
|
45
|
+
margin-top: -2rem;
|
|
46
|
+
width: 40%;
|
|
46
47
|
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);
|
|
48
|
+
text-align: center;
|
|
47
49
|
background-color: #ffc7df;
|
|
48
50
|
border-radius: .875rem;
|
|
49
|
-
flex-flow: row;
|
|
50
51
|
gap: .5rem;
|
|
51
|
-
margin-
|
|
52
|
-
|
|
52
|
+
margin-left: auto;
|
|
53
|
+
margin-right: auto;
|
|
54
|
+
padding: .75rem;
|
|
53
55
|
transition: opacity .15s ease-in-out;
|
|
54
|
-
display: flex;
|
|
55
56
|
}
|
|
56
|
-
.ndc-
|
|
57
|
+
.ndc-heading-picker-collapsed {
|
|
57
58
|
opacity: 0;
|
|
58
59
|
pointer-events: none;
|
|
59
60
|
}
|
|
60
|
-
.ndc-tab-button {
|
|
61
|
-
cursor: pointer;
|
|
62
|
-
white-space: nowrap;
|
|
63
|
-
background-color: #ffe9f3;
|
|
64
|
-
border: none;
|
|
65
|
-
border-radius: .5rem;
|
|
66
|
-
flex-shrink: 0;
|
|
67
|
-
place-content: center;
|
|
68
|
-
align-items: center;
|
|
69
|
-
padding: .55rem .85rem;
|
|
70
|
-
display: flex;
|
|
71
|
-
box-shadow: 0 0 0 .1rem #ffa6cd;
|
|
72
|
-
}
|
|
73
|
-
.ndc-tab-button:hover {
|
|
74
|
-
color: var(--novely-button-hover-color, #ffb7a2);
|
|
75
|
-
background-color: #fff;
|
|
76
|
-
}
|
|
77
61
|
.ndc-slider {
|
|
78
62
|
flex-direction: column;
|
|
79
63
|
align-items: center;
|
|
@@ -157,7 +141,7 @@
|
|
|
157
141
|
.ndc-picker-root-collapsed {
|
|
158
142
|
transform: translateY(calc(100% - 1.2rem));
|
|
159
143
|
}
|
|
160
|
-
.ndc-
|
|
144
|
+
.ndc-heading {
|
|
161
145
|
box-shadow: 0 0 0 .1rem var(--appearance-picker-tablist-border-color, #ffa6cd);
|
|
162
146
|
}
|
|
163
147
|
.ndc-slider,
|
|
@@ -196,7 +180,7 @@
|
|
|
196
180
|
border-bottom-right-radius: 0;
|
|
197
181
|
border-bottom-left-radius: 0;
|
|
198
182
|
}
|
|
199
|
-
.ndc-
|
|
183
|
+
.ndc-heading-picker-collapsed,
|
|
200
184
|
.ndc-slider-picker-collapsed {
|
|
201
185
|
opacity: 0;
|
|
202
186
|
pointer-events: none;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export type { Attributes, ClothingData, AllOptions, EmotionObject, EmotionsResult, ShowPickerOptionsAttribute, ShowPickerOptionsBase, } from './types';
|
|
2
2
|
export { generateEmotions } from './emotions';
|
|
3
|
-
declare const createDynamicCharacter: <TE extends DefaultTypeEssentials, BaseKeys extends string, Attribs extends Attributes<BaseKeys>>(_: TE, clothingData: ClothingData<BaseKeys, Attribs>, options: DynCharacterOptions<NoInfer<TE>, NoInfer<BaseKeys>, NoInfer<Attribs>>) => {
|
|
4
|
-
showPicker: () => import("@novely/core").CustomHandler;
|
|
5
|
-
showCharacter: () => import("@novely/core").CustomHandler;
|
|
6
|
-
};
|
|
7
|
-
export { createDynamicCharacter };
|