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

fix referencing of elastic easing #428

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/props.easing.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
--ease-elastic-3: var(--ease-elastic-out-3);
--ease-elastic-4: var(--ease-elastic-out-4);
--ease-elastic-5: var(--ease-elastic-out-5);
--ease-squish-1: var(--elastic-in-out-1);
--ease-squish-2: var(--elastic-in-out-2);
--ease-squish-3: var(--elastic-in-out-3);
--ease-squish-4: var(--elastic-in-out-4);
--ease-squish-5: var(--elastic-in-out-5);
--ease-squish-1: var(--ease-elastic-in-out-1);
--ease-squish-2: var(--ease-elastic-in-out-2);
--ease-squish-3: var(--ease-elastic-in-out-3);
--ease-squish-4: var(--ease-elastic-in-out-4);
--ease-squish-5: var(--ease-elastic-in-out-5);
--ease-spring-1: linear(
0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%,
0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%,
Expand Down
10 changes: 5 additions & 5 deletions src/props.easing.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ export default {
'--ease-elastic-4': 'var(--ease-elastic-out-4)',
'--ease-elastic-5': 'var(--ease-elastic-out-5)',

'--ease-squish-1': 'var(--elastic-in-out-1)',
'--ease-squish-2': 'var(--elastic-in-out-2)',
'--ease-squish-3': 'var(--elastic-in-out-3)',
'--ease-squish-4': 'var(--elastic-in-out-4)',
'--ease-squish-5': 'var(--elastic-in-out-5)',
'--ease-squish-1': 'var(--ease-elastic-in-out-1)',
'--ease-squish-2': 'var(--ease-elastic-in-out-2)',
'--ease-squish-3': 'var(--ease-elastic-in-out-3)',
'--ease-squish-4': 'var(--ease-elastic-in-out-4)',
'--ease-squish-5': 'var(--ease-elastic-in-out-5)',

'--ease-spring-1': `linear(
0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%,
Expand Down
51 changes: 51 additions & 0 deletions test/basic.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,55 @@ test('Should produce optional mask props', async t => {
test('Should produce typings files', async t => {
t.assert(fs.existsSync('./dist/open-props.module.d.ts'))
t.assert(fs.existsSync('./src/props.sizes.d.ts'))
})

test('References should be valid', async t => {
const formatter = new Intl.ListFormat();
const defined = new Set();
const referenced = new Set();
const referencedBy = new Map();

for (const [prop, value] of Object.entries(OpenProps)) {
// Add all defined variables to the defined set
defined.add(prop)

if (typeof value !== 'string') {
continue;
}

// Find all references to other variables: var(...)
const matches = value.matchAll(/var\(([^)]+)\)/g);

if (!matches) {
continue;
}

// Add all references to the referenced set
// Map all references to the prop that references them
for (const matchArray of matches) {
const reference = matchArray[1];

referenced.add(reference);

if (!prop.startsWith('--')) {
continue;
}

if (!referencedBy.has(reference)) {
referencedBy.set(reference, new Set());
}

referencedBy.get(reference).add(prop);
}
}

// Check that all referenced variables are defined
for (const reference of referenced) {
const referencing = formatter.format(Array.from(referencedBy.get(reference)));

t.assert(
defined.has(reference),
`Variable with name ${reference} was referenced by variable ${referencing}, but is not defined`
);
}
})
Loading