Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/dynamic-transitions #1533

Merged
merged 71 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f6852d8
switched accordion transition to In/Out dynamic transition
Mahmoud-zino May 21, 2023
54b4dd8
Merge branch 'dev' of https://github.com/Mahmoud-zino/skeleton into f…
Mahmoud-zino May 23, 2023
9976ca8
added TransitionSettings and removed 'any'
Mahmoud-zino May 23, 2023
5638736
deleted transition in favor of transitionIn/Out
Mahmoud-zino May 24, 2023
1ff7c0f
chagned transition types
Mahmoud-zino May 27, 2023
5444f73
foramted
Mahmoud-zino May 27, 2023
9387fdb
Merge branch 'skeletonlabs:dev' into feat/dynamic-animations
Mahmoud-zino May 27, 2023
acc9afc
changed Record value to any
Mahmoud-zino May 27, 2023
7bfe8ba
added prefersReducedMotion store
Mahmoud-zino May 28, 2023
34af502
added false to Transition type
Mahmoud-zino May 29, 2023
8508590
changed transition Types
Mahmoud-zino May 31, 2023
ea14ccb
merged dev
Mahmoud-zino May 31, 2023
ab642e7
imported Transition type
Mahmoud-zino May 31, 2023
6fc34ee
destructing Transition objects
Mahmoud-zino May 31, 2023
4649b9b
added chagneset
Mahmoud-zino May 31, 2023
e3bc2cb
moved types to types.ts, included duration in accordion transitions t…
Mahmoud-zino May 31, 2023
e99e73b
reordered duration in params
Mahmoud-zino Jun 1, 2023
1a9fc89
changed changeset message, updated imports
Mahmoud-zino Jun 1, 2023
a8cdcb7
Merge branch 'feat/dynamic-animations' of https://github.com/Mahmoud-…
Mahmoud-zino Jun 1, 2023
45b4d9d
exported transition types
Mahmoud-zino Jun 5, 2023
515dc16
Merge branch 'feat/dynamic-animations' of https://github.com/Mahmoud-…
Mahmoud-zino Jun 5, 2023
21fe122
format
Mahmoud-zino Jun 5, 2023
73fefd2
added generics attribute
AdrianGonz97 Jun 7, 2023
c55ca8a
Merge remote-tracking branch 'upstream/dev' into feat/dynamic-animations
AdrianGonz97 Jun 7, 2023
8d2f371
removed duration
AdrianGonz97 Jun 7, 2023
88defd7
exported types must be named
AdrianGonz97 Jun 7, 2023
354cdbc
oops
AdrianGonz97 Jun 7, 2023
0e79f78
added dynamicTransition function wrapper
Mahmoud-zino Jun 8, 2023
5a38990
moved dynamic-transitions types to seperate directory
Mahmoud-zino Jun 8, 2023
79cdb36
moved transition types to src/lib/types.ts
Mahmoud-zino Jun 9, 2023
bd21e34
added part of the docs
Mahmoud-zino Jun 10, 2023
dd009e6
rearrange
AdrianGonz97 Jun 14, 2023
b7524ac
Merge remote-tracking branch 'upstream/dev' into feat/dynamic-animations
AdrianGonz97 Jun 14, 2023
265bfb1
fixed jsdoc types
AdrianGonz97 Jun 14, 2023
a59bed1
Updated transition docs, added Transition tag to DocShell
endigo9740 Jun 14, 2023
379398f
Merge branch 'feat/dynamic-animations' of https://github.com/Mahmoud-…
endigo9740 Jun 14, 2023
d17a114
added prefersReducedMotion store
Mahmoud-zino Jun 14, 2023
6c6ab7d
readded AdditionalTransitionProps
Mahmoud-zino Jun 14, 2023
e1f03e9
set prefersReducedMotionStore to transitions prop
Mahmoud-zino Jun 14, 2023
c59e82f
added reducedMotion to docs
Mahmoud-zino Jun 14, 2023
995000f
added jsdoc comment to store
AdrianGonz97 Jun 14, 2023
3e53632
fixed flickering when reduced motion was on
AdrianGonz97 Jun 14, 2023
96213ba
Doc updates, props reordered, DocShell updates
endigo9740 Jun 15, 2023
105d832
switched autocomplete to dynamic transitions
Mahmoud-zino Jun 16, 2023
2f831f8
switched InputChip to dynamic transitions
Mahmoud-zino Jun 16, 2023
54b595b
switched Stepper,Step to dynamic transitions
Mahmoud-zino Jun 16, 2023
dfc6937
switched TableOfContents to dynamic transitions
Mahmoud-zino Jun 16, 2023
f0e09b1
switched Drawer to dynamic transitions
Mahmoud-zino Jun 16, 2023
1640d38
switched Modal to dynamic transitions
Mahmoud-zino Jun 16, 2023
82ad5f4
reverted drawer dynamic transitions
Mahmoud-zino Jun 16, 2023
577f634
reverted modal backdrop dynamic transition
Mahmoud-zino Jun 16, 2023
cce19d1
reverted modal backdrop dynamic transition
Mahmoud-zino Jun 16, 2023
15f3767
updated changeset
Mahmoud-zino Jun 16, 2023
4131ac1
Merge branch 'v2' into feat/dynamic-animations
Mahmoud-zino Jun 20, 2023
9f43613
deleted durations from tests
Mahmoud-zino Jun 21, 2023
56647ce
added transition style-guid
Mahmoud-zino Jun 21, 2023
dfbbfea
disable drawer opacity on demand
Mahmoud-zino Jun 23, 2023
aedd888
fixed opacityTransition type
Mahmoud-zino Jun 23, 2023
af56c60
Merge branch 'v2' into feat/dynamic-animations
Mahmoud-zino Jul 1, 2023
ea968fc
resolved conflicts, supressed a11y warnings and added todos to them
Mahmoud-zino Jul 1, 2023
30259cd
Contributor transition doc updates
endigo9740 Jul 5, 2023
25b0f2e
Note supported and non supported transitions
endigo9740 Jul 5, 2023
46d46f6
changed toast transition to fly
Mahmoud-zino Jul 6, 2023
b33b14f
removed duration from toast
Mahmoud-zino Jul 6, 2023
8aaf1ca
disable flip animation on transitions prop
Mahmoud-zino Jul 6, 2023
2c8b08f
moved SvelteEvent to types.ts
Mahmoud-zino Jul 6, 2023
59c2dd8
format
Mahmoud-zino Jul 6, 2023
f2c6cec
reapplied local to transitions to support backwards compatibility
Mahmoud-zino Jul 6, 2023
a167c32
Merge remote-tracking branch 'upstream/v2' into feat/dynamic-animations
AdrianGonz97 Jul 6, 2023
e4e93d9
chagned toast transition to global
Mahmoud-zino Jul 14, 2023
6df83bf
reordered opacityTransition to transition props
Mahmoud-zino Jul 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 23 additions & 1 deletion packages/skeleton/src/lib/components/Accordion/Accordion.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,31 @@

import { writable, type Writable } from 'svelte/store';
import { setContext } from 'svelte';
import { slide, type TransitionConfig } from 'svelte/transition';

// Types
import type { CssClasses } from '../..';
Mahmoud-zino marked this conversation as resolved.
Show resolved Hide resolved

// Props
/** Set the auto-collapse mode. */
export let autocollapse = false;
/** Set the drawer animation duration in milliseconds. */
/** DEPRECATED: use transition or transitionIn, transitionOut instead. */
endigo9740 marked this conversation as resolved.
Show resolved Hide resolved
export let duration = 200; // ms
/**
* Set the In/Out transition with it's params.
* @type {[(...args:any[]) => TransitionConfig, {}]}
*/
export let transition: [(...args: any[]) => TransitionConfig, {}] = [slide, { duration: 200 }];
/**
* Overrides the In transition with it's params.
* @type {[(...args:any[]) => TransitionConfig, {}]|undefined}
*/
export let transitionIn: [(...args: any[]) => TransitionConfig, {}] | undefined = undefined;
/**
* Overrides the Out transition with it's params.
* @type {[(...args:any[]) => TransitionConfig, {}]|undefined}
*/
export let transitionOut: [(...args: any[]) => TransitionConfig, {}] | undefined = undefined;
Mahmoud-zino marked this conversation as resolved.
Show resolved Hide resolved

// Props (parent)
/** Provide classes to set the accordion width. */
Expand Down Expand Up @@ -44,13 +60,19 @@
/** Provide arbitrary classes to the caret icon region. */
export let regionCaret: CssClasses = '';

// Silence warning about unused props:
const deprecated = [duration];

// Local
const active: Writable<string | null> = writable(null);

// Context API
setContext('active', active);
setContext('autocollapse', autocollapse);
setContext('duration', duration);
setContext('transition', transition);
setContext('transitionIn', transitionIn);
setContext('transitionOut', transitionOut);
setContext('disabled', disabled);
setContext('padding', padding);
setContext('hover', hover);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import { getContext } from 'svelte';
import { createEventDispatcher } from 'svelte/internal';
import type { Writable } from 'svelte/store';
import { slide } from 'svelte/transition';
import type { TransitionConfig } from 'svelte/transition';

// Event Dispatcher
const dispatch = createEventDispatcher();
Expand Down Expand Up @@ -41,8 +41,14 @@
export let autocollapse: boolean = getContext('autocollapse');
/** The writable store that houses the auto-collapse active item UUID. */
export let active: Writable<string | null> = getContext('active');
/** Set the drawer animation duration. */
/** DEPRECATED: use transition or transitionIn, transitionOut instead. */
endigo9740 marked this conversation as resolved.
Show resolved Hide resolved
export let duration: number = getContext('duration');
/** Set the In/Out transition. */
export let transition: [(...args: any[]) => TransitionConfig, {}] = getContext('transition');
/** Overrides the In transition with it's params. */
export let transitionIn: [(...args: any[]) => TransitionConfig, {}] = getContext('transitionIn');
/** Overrides the Out transition with it's params. */
export let transitionOut: [(...args: any[]) => TransitionConfig, {}] = getContext('transitionOut');
Mahmoud-zino marked this conversation as resolved.
Show resolved Hide resolved
// ---
/** Set the disabled state for this item. */
export let disabled: boolean = getContext('disabled');
Expand All @@ -65,6 +71,9 @@
/** Provide arbitrary classes caret icon region. */
export let regionCaret: CssClasses = getContext('regionCaret');

// Silence warning about unused props:
const deprecated = [duration];

// Change open behavior based on auto-collapse mode
function setActive(event?: Event): void {
if (autocollapse === true) {
Expand All @@ -90,6 +99,11 @@
// Reactive State
$: if (open && autocollapse) setActive();
$: openState = autocollapse ? $active === id : open;
// Reactive transition
$: trIn = transitionIn === undefined ? transition[0] : transitionIn[0];
$: trInParams = transitionIn === undefined ? transition[1] : transitionIn[1];
$: trOut = transitionOut === undefined ? transition[0] : transitionOut[0];
$: trOutParams = transitionOut === undefined ? transition[1] : transitionOut[1];
endigo9740 marked this conversation as resolved.
Show resolved Hide resolved
// Reactive Classes
$: classesBase = `${cBase} ${$$props.class ?? ''}`;
$: classesControl = `${cControl} ${padding} ${hover} ${rounded} ${regionControl}`;
Expand Down Expand Up @@ -140,7 +154,8 @@
<div
class="accordion-panel {classesPanel}"
id="accordion-panel-{id}"
transition:slide|local={{ duration }}
in:trIn|local={{ ...trInParams }}
out:trOut|local={{ ...trOutParams }}
Mahmoud-zino marked this conversation as resolved.
Show resolved Hide resolved
role="region"
aria-hidden={!openState}
aria-labelledby="accordion-control-{id}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { render } from '@testing-library/svelte';
import { describe, it, expect } from 'vitest';
import { slide } from 'svelte/transition';

import AccordionItem from '$lib/components/Accordion/AccordionItem.svelte';

describe('AccordionItem.svelte', () => {
it('Renders with minimal props', async () => {
const { getByTestId } = render(AccordionItem);
const { getByTestId } = render(AccordionItem, {
transition: [slide, { duration: 200 }]
});
expect(getByTestId('accordion-item')).toBeTruthy();
});

Expand All @@ -17,7 +20,8 @@ describe('AccordionItem.svelte', () => {
rounded: 'rounded-container-token',
regionControl: '',
regionPanel: 'space-y-4',
regionCaret: ''
regionCaret: '',
transition: [slide, { duration: 200 }]
});
expect(getByTestId('accordion-item')).toBeTruthy();
expect(getByTestId('accordion-item').querySelector('.accordion-control')?.className).to.contain('py-2 px-4');
Expand Down