This commit is contained in:
Acid Chicken (硫酸鶏) 2023-05-31 22:06:22 +09:00
parent e63db8c2ed
commit f839d6c31c
No known key found for this signature in database
GPG key ID: 3E87B98A3F6BAB99
3 changed files with 35 additions and 18 deletions

View file

@ -112,22 +112,38 @@ export function unwindCssModuleClassName(ast: estree.Node): void {
});
},
});
this.replace({
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: node.declarations[0].id.name,
},
init: {
type: 'Identifier',
name: ident,
},
}],
kind: 'const',
(walk as typeof estreeWalker.walk)(render.argument.body, {
enter(childNode) {
if (childNode.type !== 'MemberExpression') return;
if (childNode.object.type !== 'MemberExpression') return;
if (childNode.object.object.type !== 'Identifier') return;
if (childNode.object.object.name !== ctx.name) return;
if (childNode.object.property.type !== 'Identifier') return;
if (childNode.object.property.name !== key) return;
if (childNode.property.type !== 'Identifier') return;
console.error(`${key}.${childNode.property.name} is not a valid css module class name`);
this.replace({
type: 'Literal',
value: null,
});
},
});
}
this.replace({
type: 'VariableDeclaration',
declarations: [{
type: 'VariableDeclarator',
id: {
type: 'Identifier',
name: node.declarations[0].id.name,
},
init: {
type: 'Identifier',
name: ident,
},
}],
kind: 'const',
});
},
});
}
@ -138,6 +154,7 @@ export default function pluginUnwindCssModuleClassName(): Plugin {
name: 'UnwindCssModuleClassName',
renderChunk(code, chunk): { code: string } {
const ast = this.parse(code) as unknown as estree.Node;
console.log(`======= ${chunk.fileName} =======`);
unwindCssModuleClassName(ast);
return { code: generate(ast) };
},

View file

@ -8,7 +8,7 @@
$style.medias,
count === 1 ? [$style.n1, {
[$style.n116_9]: defaultStore.reactiveState.mediaListWithOneImageAppearance.value === '16_9',
[$style.n1_1]: defaultStore.reactiveState.mediaListWithOneImageAppearance.value === '1_1',
[$style.n11_1]: defaultStore.reactiveState.mediaListWithOneImageAppearance.value === '1_1',
[$style.n12_3]: defaultStore.reactiveState.mediaListWithOneImageAppearance.value === '2_3',
}] : count === 2 ? $style.n2 : count === 3 ? $style.n3 : count === 4 ? $style.n4 : $style.nMany,
]"

View file

@ -20,7 +20,7 @@
[$style.transition_send_enterFrom]: transitionName === 'send',
}"
:leaveToClass="{
[$style.transition_modalPopup_leaveTo]: transitionName === 'modal-popup',
[$style.transition_modalDrawer_leaveTo]: transitionName === 'modal-drawer',
[$style.transition_modalPopup_leaveTo]: transitionName === 'modal-popup',
[$style.transition_modal_leaveTo]: transitionName === 'modal',
[$style.transition_send_leaveTo]: transitionName === 'send',
@ -402,8 +402,8 @@ defineExpose({
transition: transform 0.2s cubic-bezier(0,.5,0,1) !important;
}
}
.transition_modal-drawer_enterFrom,
.transition_modal-drawer_leaveTo {
.transition_modalDrawer_enterFrom,
.transition_modalDrawer_leaveTo {
> .bg {
opacity: 0;
}