app-devtools 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/dist/main.d.ts +62 -0
- package/dist/main.js +2396 -0
- package/dist/main.umd.cjs +753 -0
- package/package.json +21 -16
- package/.eslintignore +0 -3
- package/.eslintrc.cjs +0 -112
- package/.gitattributes +0 -22
- package/.prettierrc +0 -10
- package/.quokka.ts +0 -115
- package/.vscode/settings.json +0 -7
- package/.vscode/snippets.code-snippets +0 -75
- package/.vscode/tasks.json +0 -17
- package/index.html +0 -46
- package/pnpm-lock.yaml +0 -5313
- package/scripts/check-if-is-sync.sh +0 -6
- package/scripts/filterFetchRequests.ts +0 -60
- package/src/Root.tsx +0 -11
- package/src/assets/icons/caret-down.svg +0 -11
- package/src/assets/icons/network.svg +0 -6
- package/src/assets/icons/search.svg +0 -3
- package/src/assets/icons/send.svg +0 -3
- package/src/assets/icons/settings.svg +0 -3
- package/src/components/ButtonElement.tsx +0 -18
- package/src/components/Icon.tsx +0 -44
- package/src/components/Section.tsx +0 -57
- package/src/components/Select.tsx +0 -101
- package/src/components/ValueVisualizer.tsx +0 -397
- package/src/config/icons.tsx +0 -23
- package/src/initializeApp.tsx +0 -28
- package/src/initializeDevTools.ts +0 -33
- package/src/main.ts +0 -42
- package/src/mocks/mockedRequests.json +0 -28391
- package/src/pages/api-explorer/ApiExplorerMenu.tsx +0 -136
- package/src/pages/api-explorer/ApiExplorerMenuItem.tsx +0 -208
- package/src/pages/api-explorer/Diff.tsx +0 -223
- package/src/pages/api-explorer/RequestDetails.tsx +0 -264
- package/src/pages/api-explorer/Timeline.tsx +0 -174
- package/src/pages/api-explorer/api-explorer.tsx +0 -21
- package/src/pages/api-explorer/getRequestPayload.tsx +0 -15
- package/src/pages/app/App.tsx +0 -79
- package/src/stores/callsStore.ts +0 -267
- package/src/stores/uiStore.ts +0 -15
- package/src/style/globalStyle.ts +0 -54
- package/src/style/helpers/allowTextSelection.ts +0 -7
- package/src/style/helpers/anchorColor.ts +0 -9
- package/src/style/helpers/centerContent.ts +0 -5
- package/src/style/helpers/circle.ts +0 -7
- package/src/style/helpers/ellipsis.ts +0 -8
- package/src/style/helpers/fillContainer.ts +0 -7
- package/src/style/helpers/gradientBorder.ts +0 -28
- package/src/style/helpers/gradientText.ts +0 -8
- package/src/style/helpers/inline.ts +0 -34
- package/src/style/helpers/mountAnim.ts +0 -26
- package/src/style/helpers/multilineEllipsis.ts +0 -8
- package/src/style/helpers/outline.ts +0 -5
- package/src/style/helpers/responsiveSize.ts +0 -27
- package/src/style/helpers/stack.ts +0 -36
- package/src/style/helpers/transition.ts +0 -63
- package/src/style/mediaQueries.ts +0 -6
- package/src/style/reset.ts +0 -75
- package/src/style/scrollBar.ts +0 -37
- package/src/style/theme.ts +0 -35
- package/src/types/global.d.ts +0 -8
- package/src/utils/initializeScreenLogger.ts +0 -12
- package/tsconfig.json +0 -36
- package/tsconfig.prod.json +0 -10
- package/tsup.config.ts +0 -7
- package/utils/arrayUtils.ts +0 -29
- package/utils/assertions.ts +0 -7
- package/utils/autoIncrementId.ts +0 -5
- package/utils/createThemev2.ts +0 -64
- package/utils/cx.ts +0 -27
- package/utils/getDiff.ts +0 -15
- package/utils/hexToRgb.ts +0 -14
- package/utils/objectUtils.ts +0 -3
- package/utils/parseUnit.ts +0 -10
- package/utils/solid.ts +0 -76
- package/utils/truncateText.ts +0 -7
- package/utils/tryExpression.ts +0 -14
- package/utils/typed.ts +0 -23
- package/utils/typings.ts +0 -40
- package/utils/urlPattern.ts +0 -25
- package/vite.config.ts +0 -46
package/src/stores/callsStore.ts
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { createStore, produce } from 'solid-js/store'
|
|
2
|
-
import { nanoid } from 'nanoid'
|
|
3
|
-
import { batch } from 'solid-js'
|
|
4
|
-
import { assertIsNotNullish } from '@utils/assertions'
|
|
5
|
-
import { tryExpression } from '@utils/tryExpression'
|
|
6
|
-
import { matchURLPattern } from '@utils/urlPattern'
|
|
7
|
-
|
|
8
|
-
export type RequestSubTypes = 'delete' | 'update' | 'create' | 'custom'
|
|
9
|
-
|
|
10
|
-
export type RequestTypes = 'fetch' | 'mutation'
|
|
11
|
-
|
|
12
|
-
export type ApiRequest = {
|
|
13
|
-
id: string
|
|
14
|
-
alias?: string
|
|
15
|
-
payload: unknown
|
|
16
|
-
response: unknown
|
|
17
|
-
metadata: unknown
|
|
18
|
-
status: number
|
|
19
|
-
isError: boolean
|
|
20
|
-
path: string
|
|
21
|
-
searchParams: Record<string, string> | null
|
|
22
|
-
type: RequestTypes
|
|
23
|
-
subType: RequestSubTypes | undefined
|
|
24
|
-
method: string | undefined
|
|
25
|
-
startTime: number
|
|
26
|
-
duration: number
|
|
27
|
-
pathParams: Record<string, string | null> | null
|
|
28
|
-
code: number | undefined
|
|
29
|
-
tags: string[]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type ApiCall = {
|
|
33
|
-
name: string
|
|
34
|
-
path: string
|
|
35
|
-
type: RequestTypes
|
|
36
|
-
subType?: RequestSubTypes
|
|
37
|
-
lastRequestStartTime: number
|
|
38
|
-
requests: ApiRequest[]
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
type State = {
|
|
42
|
-
calls: {
|
|
43
|
-
[callID: string]: ApiCall
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export const [callsStore, setCallsStore] = createStore<State>({
|
|
48
|
-
calls: {},
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
export type Config = {
|
|
52
|
-
callsProcessor: {
|
|
53
|
-
match:
|
|
54
|
-
| ((request: {
|
|
55
|
-
url: URL
|
|
56
|
-
type: RequestTypes
|
|
57
|
-
subType: RequestSubTypes | undefined
|
|
58
|
-
}) => boolean)
|
|
59
|
-
| string
|
|
60
|
-
callName?:
|
|
61
|
-
| ((request: {
|
|
62
|
-
url: URL
|
|
63
|
-
type: RequestTypes
|
|
64
|
-
subType?: RequestSubTypes
|
|
65
|
-
}) => string)
|
|
66
|
-
| string
|
|
67
|
-
callID?: (request: {
|
|
68
|
-
url: URL
|
|
69
|
-
type: RequestTypes
|
|
70
|
-
subType?: RequestSubTypes
|
|
71
|
-
}) => string
|
|
72
|
-
payloadAlias?: (payload: any, request: ApiRequest) => string
|
|
73
|
-
}[]
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let config: Config = {
|
|
77
|
-
callsProcessor: [],
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function setConfig(newConfig: Partial<Config>) {
|
|
81
|
-
config = {
|
|
82
|
-
...config,
|
|
83
|
-
...newConfig,
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function addCall(request: {
|
|
88
|
-
payload: unknown
|
|
89
|
-
response: unknown
|
|
90
|
-
metadata: unknown
|
|
91
|
-
status: number
|
|
92
|
-
isError: boolean
|
|
93
|
-
path: string
|
|
94
|
-
type: RequestTypes
|
|
95
|
-
subType?: RequestSubTypes
|
|
96
|
-
method?: string
|
|
97
|
-
startTime?: number
|
|
98
|
-
duration?: number
|
|
99
|
-
tags?: string[]
|
|
100
|
-
}) {
|
|
101
|
-
const startTime = request.startTime || Date.now()
|
|
102
|
-
|
|
103
|
-
return () => {
|
|
104
|
-
const duration = request.duration || Date.now() - startTime
|
|
105
|
-
|
|
106
|
-
setCallsStore(
|
|
107
|
-
produce((draft) => {
|
|
108
|
-
const pathURL = tryExpression(
|
|
109
|
-
() => new URL(request.path, 'http://localhost'),
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
assertIsNotNullish(pathURL)
|
|
113
|
-
|
|
114
|
-
const searchParams =
|
|
115
|
-
pathURL.searchParams.toString() !== ''
|
|
116
|
-
? Object.fromEntries(pathURL.searchParams.entries())
|
|
117
|
-
: null
|
|
118
|
-
|
|
119
|
-
let pathParams: Record<string, string | null> | null = null
|
|
120
|
-
|
|
121
|
-
const relatedConfig = config.callsProcessor.find((processor) => {
|
|
122
|
-
if (typeof processor.match === 'string') {
|
|
123
|
-
const pattern = matchURLPattern(pathURL.pathname, processor.match)
|
|
124
|
-
|
|
125
|
-
if (pattern) {
|
|
126
|
-
pathParams = pattern
|
|
127
|
-
return true
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return false
|
|
131
|
-
} else {
|
|
132
|
-
return processor.match({
|
|
133
|
-
url: pathURL,
|
|
134
|
-
type: request.type,
|
|
135
|
-
subType: request.subType,
|
|
136
|
-
})
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
const normalizedCallId =
|
|
141
|
-
relatedConfig?.callID?.({
|
|
142
|
-
url: pathURL,
|
|
143
|
-
type: request.type,
|
|
144
|
-
subType: request.subType,
|
|
145
|
-
}) ||
|
|
146
|
-
(typeof relatedConfig?.match === 'string' && relatedConfig.match)
|
|
147
|
-
|
|
148
|
-
const callID = btoa(
|
|
149
|
-
normalizedCallId ||
|
|
150
|
-
`${pathURL.pathname}|${request.type}${
|
|
151
|
-
request.subType ? `|${request.subType}` : ''
|
|
152
|
-
}`,
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
const callNameNormalizer = relatedConfig?.callName
|
|
156
|
-
|
|
157
|
-
const normalizedCallName =
|
|
158
|
-
typeof callNameNormalizer === 'function'
|
|
159
|
-
? callNameNormalizer({
|
|
160
|
-
url: pathURL,
|
|
161
|
-
type: request.type,
|
|
162
|
-
subType: request.subType,
|
|
163
|
-
})
|
|
164
|
-
: callNameNormalizer
|
|
165
|
-
|
|
166
|
-
if (!draft.calls[callID]) {
|
|
167
|
-
draft.calls[callID] = {
|
|
168
|
-
name:
|
|
169
|
-
normalizedCallName ||
|
|
170
|
-
(typeof relatedConfig?.match === 'string' &&
|
|
171
|
-
relatedConfig.match) ||
|
|
172
|
-
pathURL.pathname.replace(/^\//, ''),
|
|
173
|
-
path: pathURL.pathname.replace(/^\//, ''),
|
|
174
|
-
lastRequestStartTime: startTime,
|
|
175
|
-
requests: [],
|
|
176
|
-
type: request.type,
|
|
177
|
-
subType: request.subType,
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const call = draft.calls[callID]
|
|
182
|
-
|
|
183
|
-
assertIsNotNullish(call)
|
|
184
|
-
|
|
185
|
-
if (call.requests.length > 100) {
|
|
186
|
-
call.requests.shift()
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const requestToAdd: ApiRequest = {
|
|
190
|
-
id: nanoid(),
|
|
191
|
-
duration,
|
|
192
|
-
pathParams,
|
|
193
|
-
isError: request.isError,
|
|
194
|
-
metadata: request.metadata,
|
|
195
|
-
path: request.path.replace(/^\//, ''),
|
|
196
|
-
payload: request.payload,
|
|
197
|
-
response: request.response,
|
|
198
|
-
searchParams,
|
|
199
|
-
status: request.status,
|
|
200
|
-
startTime,
|
|
201
|
-
type: request.type,
|
|
202
|
-
method: request.method,
|
|
203
|
-
subType: request.subType,
|
|
204
|
-
code: request.status,
|
|
205
|
-
tags: request.tags || [],
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const payloadAlias = tryExpression(() =>
|
|
209
|
-
relatedConfig?.payloadAlias?.(requestToAdd.payload, requestToAdd),
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
if (payloadAlias) {
|
|
213
|
-
requestToAdd.alias = payloadAlias
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
call.requests.push(requestToAdd)
|
|
217
|
-
}),
|
|
218
|
-
)
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (import.meta.env.DEV) {
|
|
223
|
-
const mockedCalls = await import('@src/mocks/mockedRequests.json')
|
|
224
|
-
|
|
225
|
-
setTimeout(() => {
|
|
226
|
-
batch(() => {
|
|
227
|
-
mockedCalls.default.forEach((call) => {
|
|
228
|
-
addCall({
|
|
229
|
-
payload: call.request.payload,
|
|
230
|
-
response: call.response.body,
|
|
231
|
-
metadata: call.metadata,
|
|
232
|
-
status: call.response.status,
|
|
233
|
-
isError: call.response.status >= 400,
|
|
234
|
-
path: call.request.path,
|
|
235
|
-
type:
|
|
236
|
-
call.request.method === 'GET'
|
|
237
|
-
? 'fetch'
|
|
238
|
-
: call.request.path.includes('update')
|
|
239
|
-
? 'mutation'
|
|
240
|
-
: 'fetch',
|
|
241
|
-
subType: ((): RequestSubTypes | undefined => {
|
|
242
|
-
if (call.request.path.includes('delete')) {
|
|
243
|
-
return 'delete'
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (call.request.path.includes('update')) {
|
|
247
|
-
return 'update'
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (call.request.path.includes('create')) {
|
|
251
|
-
return 'create'
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (call.request.path.includes('custom')) {
|
|
255
|
-
return 'custom'
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
return undefined
|
|
259
|
-
})(),
|
|
260
|
-
method: call.request.method,
|
|
261
|
-
startTime: call.stats.startTime,
|
|
262
|
-
duration: call.stats.time,
|
|
263
|
-
})()
|
|
264
|
-
})
|
|
265
|
-
})
|
|
266
|
-
}, 1)
|
|
267
|
-
}
|
package/src/stores/uiStore.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createStore } from 'solid-js/store'
|
|
2
|
-
|
|
3
|
-
type State = {
|
|
4
|
-
selectedCall: string | null
|
|
5
|
-
selectedRequest: string | null
|
|
6
|
-
selectedTab: string | null
|
|
7
|
-
selectedSubitem: string | null
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const [uiStore, setUiStore] = createStore<State>({
|
|
11
|
-
selectedCall: null,
|
|
12
|
-
selectedRequest: null,
|
|
13
|
-
selectedTab: null,
|
|
14
|
-
selectedSubitem: null,
|
|
15
|
-
})
|
package/src/style/globalStyle.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { colors, fonts } from '@src/style/theme'
|
|
2
|
-
|
|
3
|
-
export const globalStyle = `
|
|
4
|
-
font-family: ${fonts.primary};
|
|
5
|
-
color: ${colors.textPrimary.var};
|
|
6
|
-
|
|
7
|
-
* {
|
|
8
|
-
user-select: none;
|
|
9
|
-
position: relative;
|
|
10
|
-
-webkit-tap-highlight-color: transparent;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
input,
|
|
14
|
-
textarea,
|
|
15
|
-
p,
|
|
16
|
-
pre,
|
|
17
|
-
h1,
|
|
18
|
-
h2 {
|
|
19
|
-
user-select: text;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
:is(input, textarea, p, pre, h1, h2) * {
|
|
23
|
-
user-select: text;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
a {
|
|
27
|
-
--anchor-color: inherit;
|
|
28
|
-
color: var(---anchor-color);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
a:visited {
|
|
32
|
-
color: var(---anchor-color);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
button {
|
|
36
|
-
color: inherit;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
p,
|
|
40
|
-
h1,
|
|
41
|
-
h2,
|
|
42
|
-
h3 {
|
|
43
|
-
font-size: inherit;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
h1 {
|
|
47
|
-
font-weight: normal;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
h2,
|
|
51
|
-
h3 {
|
|
52
|
-
font-weight: normal;
|
|
53
|
-
}
|
|
54
|
-
`
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export function gradientBorder({
|
|
2
|
-
gradient,
|
|
3
|
-
background,
|
|
4
|
-
borderSize = 1,
|
|
5
|
-
borderOpacity = 0,
|
|
6
|
-
}: {
|
|
7
|
-
gradient: string
|
|
8
|
-
background: string
|
|
9
|
-
borderSize?: number
|
|
10
|
-
borderOpacity?: number
|
|
11
|
-
}) {
|
|
12
|
-
return `
|
|
13
|
-
position: relative;
|
|
14
|
-
isolation: isolate;
|
|
15
|
-
background: ${gradient};
|
|
16
|
-
|
|
17
|
-
&::before {
|
|
18
|
-
content: '';
|
|
19
|
-
inset: 0;
|
|
20
|
-
border-radius: inherit;
|
|
21
|
-
z-index: -1;
|
|
22
|
-
border: ${borderSize}px solid rgba(0, 0, 0, ${borderOpacity});
|
|
23
|
-
background: ${background};
|
|
24
|
-
position: absolute;
|
|
25
|
-
background-clip: padding-box;
|
|
26
|
-
}
|
|
27
|
-
`
|
|
28
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const justifyValues = {
|
|
2
|
-
left: 'flex-start',
|
|
3
|
-
center: 'center',
|
|
4
|
-
right: 'flex-end',
|
|
5
|
-
spaceBetween: 'space-between',
|
|
6
|
-
spaceAround: 'space-around',
|
|
7
|
-
spaceEvenly: 'space-evenly',
|
|
8
|
-
} as const
|
|
9
|
-
|
|
10
|
-
const alignValues = {
|
|
11
|
-
top: 'flex-start',
|
|
12
|
-
bottom: 'flex-end',
|
|
13
|
-
center: 'center',
|
|
14
|
-
stretch: 'stretch',
|
|
15
|
-
} as const
|
|
16
|
-
|
|
17
|
-
export type InlineProps = {
|
|
18
|
-
justify?: keyof typeof justifyValues
|
|
19
|
-
align?: keyof typeof alignValues
|
|
20
|
-
gap?: string | number
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const inline = ({
|
|
24
|
-
justify = 'left',
|
|
25
|
-
align = 'center',
|
|
26
|
-
gap,
|
|
27
|
-
}: InlineProps = {}) =>
|
|
28
|
-
`
|
|
29
|
-
display: flex;
|
|
30
|
-
column-gap: ${gap}px;
|
|
31
|
-
flex-direction: row;
|
|
32
|
-
justify-content: ${justifyValues[justify]};
|
|
33
|
-
align-items: ${alignValues[align]};
|
|
34
|
-
`
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
easings,
|
|
3
|
-
TransitionDurations,
|
|
4
|
-
transitionDurations,
|
|
5
|
-
TransitionEasings,
|
|
6
|
-
} from '@src/style/helpers/transition'
|
|
7
|
-
|
|
8
|
-
export const fadeIn = ({
|
|
9
|
-
duration = 'medium',
|
|
10
|
-
ease = 'linear',
|
|
11
|
-
}: {
|
|
12
|
-
opacity?: number
|
|
13
|
-
duration?: TransitionDurations | number
|
|
14
|
-
ease?: TransitionEasings
|
|
15
|
-
} = {}) => `
|
|
16
|
-
animation: ${
|
|
17
|
-
typeof duration === 'number' ? duration : transitionDurations[duration]
|
|
18
|
-
}ms
|
|
19
|
-
${easings[ease]} fade;
|
|
20
|
-
|
|
21
|
-
@keyframes fade {
|
|
22
|
-
from {
|
|
23
|
-
opacity: 0;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
`
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { parseUnit } from '@utils/parseUnit'
|
|
2
|
-
|
|
3
|
-
type Unit = string | number
|
|
4
|
-
|
|
5
|
-
// TODO: add two margin options
|
|
6
|
-
|
|
7
|
-
function getDimension(margin: Unit | [Unit, Unit]) {
|
|
8
|
-
return Array.isArray(margin)
|
|
9
|
-
? `calc(100% - (${parseUnit(margin[0])} + ${parseUnit(margin[1])}))`
|
|
10
|
-
: `calc(100% - (${parseUnit(margin)} * 2))`
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const responsiveWidth = (
|
|
14
|
-
maxWidth: Unit,
|
|
15
|
-
margin: Unit | [Unit, Unit] = 0,
|
|
16
|
-
) => `
|
|
17
|
-
max-width: ${parseUnit(maxWidth)};
|
|
18
|
-
width: ${getDimension(margin)};
|
|
19
|
-
`
|
|
20
|
-
|
|
21
|
-
export const responsiveHeight = (
|
|
22
|
-
height: Unit,
|
|
23
|
-
margin: Unit | [Unit, Unit] = 0,
|
|
24
|
-
) => `
|
|
25
|
-
max-height: ${parseUnit(height)};
|
|
26
|
-
height: ${getDimension(margin)};
|
|
27
|
-
`
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const justifyValues = {
|
|
2
|
-
top: 'flex-start',
|
|
3
|
-
center: 'center',
|
|
4
|
-
bottom: 'flex-end',
|
|
5
|
-
spaceBetween: 'space-between',
|
|
6
|
-
spaceAround: 'space-around',
|
|
7
|
-
spaceEvenly: 'space-evenly',
|
|
8
|
-
} as const
|
|
9
|
-
|
|
10
|
-
const alignValues = {
|
|
11
|
-
left: 'flex-start',
|
|
12
|
-
right: 'flex-end',
|
|
13
|
-
center: 'center',
|
|
14
|
-
stretch: 'stretch',
|
|
15
|
-
} as const
|
|
16
|
-
|
|
17
|
-
export type StackProps = {
|
|
18
|
-
justify?: keyof typeof justifyValues
|
|
19
|
-
align?: keyof typeof alignValues
|
|
20
|
-
gap?: string | number
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// TODO: change spacing to gap
|
|
24
|
-
|
|
25
|
-
export const stack = ({
|
|
26
|
-
justify = 'top',
|
|
27
|
-
align = 'stretch',
|
|
28
|
-
gap = 0,
|
|
29
|
-
}: StackProps = {}) =>
|
|
30
|
-
`
|
|
31
|
-
row-gap: ${gap}px;
|
|
32
|
-
display: flex;
|
|
33
|
-
flex-direction: column;
|
|
34
|
-
justify-content: ${justifyValues[justify]};
|
|
35
|
-
align-items: ${alignValues[align]};
|
|
36
|
-
`
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export const transitionDurations = {
|
|
2
|
-
short: 160,
|
|
3
|
-
medium: 240,
|
|
4
|
-
long: 360,
|
|
5
|
-
} as const
|
|
6
|
-
|
|
7
|
-
export type TransitionDurations = keyof typeof transitionDurations
|
|
8
|
-
|
|
9
|
-
export const easings = {
|
|
10
|
-
inOut: 'cubic-bezier(0.4, 0.0, 0.2, 1)',
|
|
11
|
-
out: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
|
|
12
|
-
in: 'cubic-bezier(0.4, 0.0, 1, 1)',
|
|
13
|
-
linear: 'linear',
|
|
14
|
-
} as const
|
|
15
|
-
|
|
16
|
-
export type TransitionEasings = keyof typeof easings
|
|
17
|
-
|
|
18
|
-
type Props = {
|
|
19
|
-
duration?: TransitionDurations | number
|
|
20
|
-
ease?: TransitionEasings
|
|
21
|
-
properties?: string[]
|
|
22
|
-
delay?: number
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type ArrayProp = {
|
|
26
|
-
property?: string
|
|
27
|
-
duration?: TransitionDurations | number
|
|
28
|
-
ease?: TransitionEasings
|
|
29
|
-
delay?: number
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const appendMs = (value?: string | number) =>
|
|
33
|
-
value !== undefined ? `${value}ms` : ''
|
|
34
|
-
|
|
35
|
-
export function transitionShorthand({
|
|
36
|
-
property,
|
|
37
|
-
duration = 'medium',
|
|
38
|
-
ease = 'inOut',
|
|
39
|
-
delay,
|
|
40
|
-
}: ArrayProp = {}) {
|
|
41
|
-
return `${property || ''} ${appendMs(
|
|
42
|
-
typeof duration === 'number' ? duration : transitionDurations[duration],
|
|
43
|
-
)} ${easings[ease]} ${appendMs(delay)}`
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function transition(props: Props = {}): string {
|
|
47
|
-
const { properties, duration, ease, delay } = props
|
|
48
|
-
|
|
49
|
-
return `
|
|
50
|
-
transition: ${appendMs(
|
|
51
|
-
typeof duration === 'number'
|
|
52
|
-
? duration
|
|
53
|
-
: transitionDurations[duration || 'medium'],
|
|
54
|
-
)} ${easings[ease || 'inOut']} ${appendMs(delay)};
|
|
55
|
-
${
|
|
56
|
-
properties
|
|
57
|
-
? `
|
|
58
|
-
transition-property: ${properties.join(', ') || ''};
|
|
59
|
-
`
|
|
60
|
-
: ''
|
|
61
|
-
}
|
|
62
|
-
`
|
|
63
|
-
}
|