842890d054
* ensure `appear` works in combination with SSR * add appear transition example * update changelog * add scale to appear example * trigger immediate transition once the DOM is ready * ensure React doesn't change the `className` underneath us * handle all base classes We are bypassing React when handling classes in the Transition component. Let's ensure the base classes from the prop are also added correctly. * add missing `base` to tests * simplify `useTransition` hook * add react-hot-toast example * make TS happy * ensure the `classNames` are unique * remove classNames if it results in an empty string This will ensure that we don't end up with `class=""` in the DOM * ensure `unmount` is defaulting to `true` * do not read from `prevShow` in render After fixing the other bugs, this part only caused bugs right now. Even when re-rendering the Transition component while transitioning. Dropping this fixes that behaviour. * extend `appear` demo with appear, show, unmount booleans + a `lazily` one to mimic a conditional render on the client instead of a fresh page refresh.
16 lines
318 B
TypeScript
16 lines
318 B
TypeScript
export function classNames(...classes: (false | null | undefined | string)[]): string {
|
|
return Array.from(
|
|
new Set(
|
|
classes.flatMap((value) => {
|
|
if (typeof value === 'string') {
|
|
return value.split(' ')
|
|
}
|
|
|
|
return []
|
|
})
|
|
)
|
|
)
|
|
.filter(Boolean)
|
|
.join(' ')
|
|
}
|