refactor(client): use css modules

This commit is contained in:
syuilo 2023-01-10 09:41:53 +09:00
parent 7bdff90415
commit 7823ba494f
1 changed files with 50 additions and 50 deletions

View File

@ -1,10 +1,10 @@
<template> <template>
<MkModal ref="modal" :prefer-type="'dialog'" :z-priority="'high'" @click="done(true)" @closed="emit('closed')"> <MkModal ref="modal" :prefer-type="'dialog'" :z-priority="'high'" @click="done(true)" @closed="emit('closed')">
<div class="mk-dialog"> <div :class="$style.root">
<div v-if="icon" class="icon"> <div v-if="icon" :class="$style.icon">
<i :class="icon"></i> <i :class="icon"></i>
</div> </div>
<div v-else-if="!input && !select" class="icon" :class="type"> <div v-else-if="!input && !select" :class="[$style.icon, type]">
<i v-if="type === 'success'" class="ti ti-check"></i> <i v-if="type === 'success'" class="ti ti-check"></i>
<i v-else-if="type === 'error'" class="ti ti-circle-x"></i> <i v-else-if="type === 'error'" class="ti ti-circle-x"></i>
<i v-else-if="type === 'warning'" class="ti ti-alert-triangle"></i> <i v-else-if="type === 'warning'" class="ti ti-alert-triangle"></i>
@ -12,8 +12,8 @@
<i v-else-if="type === 'question'" class="ti ti-question-circle"></i> <i v-else-if="type === 'question'" class="ti ti-question-circle"></i>
<MkLoading v-else-if="type === 'waiting'" :em="true"/> <MkLoading v-else-if="type === 'waiting'" :em="true"/>
</div> </div>
<header v-if="title"><Mfm :text="title"/></header> <header v-if="title" :class="$style.title"><Mfm :text="title"/></header>
<div v-if="text" class="body"><Mfm :text="text"/></div> <div v-if="text" :class="$style.text"><Mfm :text="text"/></div>
<MkInput v-if="input" v-model="inputValue" autofocus :type="input.type || 'text'" :placeholder="input.placeholder || undefined" @keydown="onInputKeydown"> <MkInput v-if="input" v-model="inputValue" autofocus :type="input.type || 'text'" :placeholder="input.placeholder || undefined" @keydown="onInputKeydown">
<template v-if="input.type === 'password'" #prefix><i class="ti ti-lock"></i></template> <template v-if="input.type === 'password'" #prefix><i class="ti ti-lock"></i></template>
</MkInput> </MkInput>
@ -27,11 +27,11 @@
</optgroup> </optgroup>
</template> </template>
</MkSelect> </MkSelect>
<div v-if="(showOkButton || showCancelButton) && !actions" class="buttons"> <div v-if="(showOkButton || showCancelButton) && !actions" :class="$style.buttons">
<MkButton v-if="showOkButton" inline primary :autofocus="!input && !select" @click="ok">{{ (showCancelButton || input || select) ? i18n.ts.ok : i18n.ts.gotIt }}</MkButton> <MkButton v-if="showOkButton" inline primary :autofocus="!input && !select" @click="ok">{{ (showCancelButton || input || select) ? i18n.ts.ok : i18n.ts.gotIt }}</MkButton>
<MkButton v-if="showCancelButton || input || select" inline @click="cancel">{{ i18n.ts.cancel }}</MkButton> <MkButton v-if="showCancelButton || input || select" inline @click="cancel">{{ i18n.ts.cancel }}</MkButton>
</div> </div>
<div v-if="actions" class="buttons"> <div v-if="actions" :class="$style.buttons">
<MkButton v-for="action in actions" :key="action.text" inline :primary="action.primary" @click="() => { action.callback(); close(); }">{{ action.text }}</MkButton> <MkButton v-for="action in actions" :key="action.text" inline :primary="action.primary" @click="() => { action.callback(); close(); }">{{ action.text }}</MkButton>
</div> </div>
</div> </div>
@ -143,8 +143,8 @@ onBeforeUnmount(() => {
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" module>
.mk-dialog { .root {
position: relative; position: relative;
padding: 32px; padding: 32px;
min-width: 320px; min-width: 320px;
@ -153,8 +153,9 @@ onBeforeUnmount(() => {
text-align: center; text-align: center;
background: var(--panel); background: var(--panel);
border-radius: var(--radius); border-radius: var(--radius);
}
> .icon { .icon {
font-size: 24px; font-size: 24px;
&.info { &.info {
@ -178,31 +179,30 @@ onBeforeUnmount(() => {
margin: 0 auto; margin: 0 auto;
} }
& + header { & + .title {
margin-top: 8px; margin-top: 8px;
} }
} }
> header { .title {
margin: 0 0 8px 0; margin: 0 0 8px 0;
font-weight: bold; font-weight: bold;
font-size: 1.1em; font-size: 1.1em;
& + .body { & + .text {
margin-top: 8px; margin-top: 8px;
} }
} }
> .body { .text {
margin: 16px 0 0 0; margin: 16px 0 0 0;
} }
> .buttons { .buttons {
margin-top: 16px; margin-top: 16px;
display: flex;
> * { gap: 8px;
margin: 0 8px; flex-wrap: wrap;
} justify-content: center;
}
} }
</style> </style>