refactor(client): use css modules
This commit is contained in:
parent
d075471b2d
commit
bb5d2bda51
1 changed files with 44 additions and 39 deletions
|
@ -1,32 +1,34 @@
|
||||||
<template>
|
<template>
|
||||||
<button
|
<button
|
||||||
v-if="!link"
|
v-if="!link"
|
||||||
ref="el" class="bghgjjyj _button"
|
ref="el" class="_button"
|
||||||
:class="{ inline, primary, gradate, danger, rounded, full, small, large, asLike }"
|
:class="[$style.root, { [$style.inline]: inline, [$style.primary]: primary, [$style.gradate]: gradate, [$style.danger]: danger, [$style.rounded]: rounded, [$style.full]: full, [$style.small]: small, [$style.large]: large, [$style.asLike]: asLike }]"
|
||||||
:type="type"
|
:type="type"
|
||||||
@click="emit('click', $event)"
|
@click="emit('click', $event)"
|
||||||
@mousedown="onMousedown"
|
@mousedown="onMousedown"
|
||||||
>
|
>
|
||||||
<div ref="ripples" class="ripples"></div>
|
<div ref="ripples" :class="$style.ripples"></div>
|
||||||
<div class="content">
|
<div :class="$style.content">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<MkA
|
<MkA
|
||||||
v-else class="bghgjjyj _button"
|
v-else class="_button"
|
||||||
:class="{ inline, primary, gradate, danger, rounded, full, small }"
|
:class="[$style.root, { [$style.inline]: inline, [$style.primary]: primary, [$style.gradate]: gradate, [$style.danger]: danger, [$style.rounded]: rounded, [$style.full]: full, [$style.small]: small, [$style.large]: large, [$style.asLike]: asLike }]"
|
||||||
:to="to"
|
:to="to"
|
||||||
@mousedown="onMousedown"
|
@mousedown="onMousedown"
|
||||||
>
|
>
|
||||||
<div ref="ripples" class="ripples"></div>
|
<div ref="ripples" :class="$style.ripples"></div>
|
||||||
<div class="content">
|
<div :class="$style.content">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
</MkA>
|
</MkA>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { nextTick, onMounted } from 'vue';
|
import { nextTick, onMounted, useCssModule } from 'vue';
|
||||||
|
|
||||||
|
const $style = useCssModule();
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
type?: 'button' | 'submit' | 'reset';
|
type?: 'button' | 'submit' | 'reset';
|
||||||
|
@ -78,6 +80,7 @@ function onMousedown(evt: MouseEvent): void {
|
||||||
const rect = target.getBoundingClientRect();
|
const rect = target.getBoundingClientRect();
|
||||||
|
|
||||||
const ripple = document.createElement('div');
|
const ripple = document.createElement('div');
|
||||||
|
ripple.classList.add($style.ripple);
|
||||||
ripple.style.top = (evt.clientY - rect.top - 1).toString() + 'px';
|
ripple.style.top = (evt.clientY - rect.top - 1).toString() + 'px';
|
||||||
ripple.style.left = (evt.clientX - rect.left - 1).toString() + 'px';
|
ripple.style.left = (evt.clientX - rect.left - 1).toString() + 'px';
|
||||||
|
|
||||||
|
@ -101,8 +104,8 @@ function onMousedown(evt: MouseEvent): void {
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" module>
|
||||||
.bghgjjyj {
|
.root {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1; // 他コンポーネントのbox-shadowに隠されないようにするため
|
z-index: 1; // 他コンポーネントのbox-shadowに隠されないようにするため
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -173,7 +176,7 @@ function onMousedown(evt: MouseEvent): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
> .ripples {
|
> .ripples {
|
||||||
::v-deep(div) {
|
> .ripple {
|
||||||
background: rgba(255, 60, 106, 0.15);
|
background: rgba(255, 60, 106, 0.15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +240,12 @@ function onMousedown(evt: MouseEvent): void {
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .ripples {
|
&.primary > .ripples > .ripple {
|
||||||
|
background: rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ripples {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
@ -246,8 +254,10 @@ function onMousedown(evt: MouseEvent): void {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
overflow: clip;
|
overflow: clip;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
::v-deep(div) {
|
.ripple {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 2px;
|
width: 2px;
|
||||||
height: 2px;
|
height: 2px;
|
||||||
|
@ -256,16 +266,11 @@ function onMousedown(evt: MouseEvent): void {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
transition: all 0.5s cubic-bezier(0,.5,0,1);
|
transition: all 0.5s cubic-bezier(0,.5,0,1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
&.primary > .ripples ::v-deep(div) {
|
.content {
|
||||||
background: rgba(0, 0, 0, 0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
> .content {
|
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue