Skip to content

Commit

Permalink
feat: 添加滑块示例
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxian521 committed Dec 19, 2024
1 parent f8690a0 commit bbdd44a
Show file tree
Hide file tree
Showing 24 changed files with 375 additions and 16 deletions.
1 change: 1 addition & 0 deletions locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ menus:
pureDraggable: Draggable
pureSplitPane: Split Pane
pureText: Text Ellipsis
pureSlider: Slider
pureElButton: Button
pureButton: Button Animation
pureCheckButton: Check Button
Expand Down
1 change: 1 addition & 0 deletions locales/zh-CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ menus:
pureDraggable: 拖拽
pureSplitPane: 切割面板
pureText: 文本省略
pureSlider: 滑块
pureElButton: 按钮
pureCheckButton: 可选按钮
pureButton: 按钮动效
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReText/src/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts" setup>
<script setup lang="ts">
import { h, onMounted, ref, useSlots } from "vue";
import { type TippyOptions, useTippy } from "vue-tippy";
Expand Down
2 changes: 1 addition & 1 deletion src/layout/components/lay-footer/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script lang="ts" setup>
<script setup lang="ts">
import { getConfig } from "@/config";
const TITLE = getConfig("Title");
Expand Down
16 changes: 11 additions & 5 deletions src/router/modules/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export default {
name: "CheckCard",
component: () => import("@/views/components/check-card.vue"),
meta: {
title: $t("menus.pureCheckCard"),
extraIcon: "IF-pure-iconfont-new svg"
title: $t("menus.pureCheckCard")
}
},
{
Expand Down Expand Up @@ -112,7 +111,15 @@ export default {
name: "PureText",
component: () => import("@/views/components/text.vue"),
meta: {
title: $t("menus.pureText"),
title: $t("menus.pureText")
}
},
{
path: "/components/slider",
name: "PureSlider",
component: () => import("@/views/components/slider/index.vue"),
meta: {
title: $t("menus.pureSlider"),
extraIcon: "IF-pure-iconfont-new svg"
}
},
Expand All @@ -129,8 +136,7 @@ export default {
name: "CheckButton",
component: () => import("@/views/components/check-button.vue"),
meta: {
title: $t("menus.pureCheckButton"),
extraIcon: "IF-pure-iconfont-new svg"
title: $t("menus.pureCheckButton")
}
},
{
Expand Down
64 changes: 64 additions & 0 deletions src/views/components/slider/components/Base.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<script setup lang="ts">
import { ref } from "vue";
const value1 = ref(0);
const value2 = ref(10);
const value3 = ref(0);
const value4 = ref(0);
const value5 = ref(0);
const formatTooltip = (val: number) => {
return val / 100;
};
</script>

<template>
<div class="slider-demo-block">
<span class="demonstration">默认值</span>
<el-slider v-model="value1" />
</div>
<div class="slider-demo-block">
<span class="demonstration">自定义初始值</span>
<el-slider v-model="value2" />
</div>
<div class="slider-demo-block">
<span class="demonstration">隐藏 Tooltip 提示</span>
<el-slider v-model="value3" :show-tooltip="false" />
</div>
<div class="slider-demo-block">
<span class="demonstration">格式化 Tooltip 提示</span>
<el-slider v-model="value4" :format-tooltip="formatTooltip" />
</div>
<div class="slider-demo-block">
<span class="demonstration">禁用</span>
<el-slider v-model="value5" disabled />
</div>
</template>

<style lang="scss" scoped>
.slider-demo-block {
display: flex;
align-items: center;
max-width: 600px;
}
.slider-demo-block .el-slider {
margin-top: 0;
margin-left: 12px;
}
.slider-demo-block .demonstration {
flex: 1;
margin-bottom: 0;
overflow: hidden;
font-size: 14px;
line-height: 44px;
color: var(--el-text-color-secondary);
text-overflow: ellipsis;
white-space: nowrap;
}
.slider-demo-block .demonstration + .el-slider {
flex: 0 0 70%;
}
</style>
24 changes: 24 additions & 0 deletions src/views/components/slider/components/Input.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { ref } from "vue";
const value = ref(0);
</script>

<template>
<div class="slider-demo-block">
<el-slider v-model="value" show-input />
</div>
</template>

<style lang="scss" scoped>
.slider-demo-block {
display: flex;
align-items: center;
max-width: 600px;
}
.slider-demo-block .el-slider {
margin-top: 0;
margin-left: 12px;
}
</style>
43 changes: 43 additions & 0 deletions src/views/components/slider/components/Marks.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<script setup lang="ts">
import { reactive, ref } from "vue";
import type { CSSProperties } from "vue";
interface Mark {
style: CSSProperties;
label: string;
}
type Marks = Record<number, Mark | string>;
const value = ref([30, 60]);
const marks = reactive<Marks>({
0: "0°C",
8: "8°C",
37: "37°C",
50: {
style: {
color: "#1989FA"
},
label: "50%"
}
});
</script>

<template>
<div class="slider-demo-block">
<el-slider v-model="value" range :marks="marks" />
</div>
</template>

<style lang="scss" scoped>
.slider-demo-block {
display: flex;
align-items: center;
max-width: 600px;
}
.slider-demo-block .el-slider {
margin-top: 0;
margin-left: 12px;
}
</style>
40 changes: 40 additions & 0 deletions src/views/components/slider/components/Placement.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<script setup lang="ts">
import { ref } from "vue";
const value1 = ref(0);
const value2 = ref(0);
const value3 = ref(0);
const value4 = ref(0);
</script>

<template>
<div class="slider-demo-block">
<span class="mr-2">上</span>
<el-slider v-model="value1" />
</div>
<div class="slider-demo-block">
<span class="mr-2">下</span>
<el-slider v-model="value2" placement="bottom" />
</div>
<div class="slider-demo-block">
<span class="mr-2">左</span>
<el-slider v-model="value4" placement="left" />
</div>
<div class="slider-demo-block">
<span class="mr-2">右</span>
<el-slider v-model="value3" placement="right" />
</div>
</template>

<style lang="scss" scoped>
.slider-demo-block {
display: flex;
align-items: center;
max-width: 600px;
}
.slider-demo-block .el-slider {
margin-top: 0;
margin-left: 12px;
}
</style>
24 changes: 24 additions & 0 deletions src/views/components/slider/components/Range.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { ref } from "vue";
const value = ref([4, 8]);
</script>

<template>
<div class="slider-demo-block">
<el-slider v-model="value" range show-stops :max="10" />
</div>
</template>

<style lang="scss" scoped>
.slider-demo-block {
display: flex;
align-items: center;
max-width: 600px;
}
.slider-demo-block .el-slider {
margin-top: 0;
margin-left: 12px;
}
</style>
23 changes: 23 additions & 0 deletions src/views/components/slider/components/Size.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script setup lang="ts">
import { ref } from "vue";
const value = ref(0);
</script>

<template>
<div class="max-w-[600px] ml-4">
<el-slider v-model="value" show-input size="large" />
<el-slider v-model="value" show-input />
<el-slider v-model="value" show-input size="small" />
</div>
</template>

<style lang="scss" scoped>
.el-slider {
margin-top: 20px;
}
.el-slider:first-child {
margin-top: 0;
}
</style>
45 changes: 45 additions & 0 deletions src/views/components/slider/components/Step.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<script setup lang="ts">
import { ref } from "vue";
const value1 = ref(0);
const value2 = ref(0);
</script>

<template>
<div class="slider-demo-block">
<span class="demonstration">不显示断点</span>
<el-slider v-model="value1" :step="10" />
</div>
<div class="slider-demo-block">
<span class="demonstration">显示断点</span>
<el-slider v-model="value2" :step="10" show-stops />
</div>
</template>

<style lang="scss" scoped>
.slider-demo-block {
display: flex;
align-items: center;
max-width: 600px;
}
.slider-demo-block .el-slider {
margin-top: 0;
margin-left: 12px;
}
.slider-demo-block .demonstration {
flex: 1;
margin-bottom: 0;
overflow: hidden;
font-size: 14px;
line-height: 44px;
color: var(--el-text-color-secondary);
text-overflow: ellipsis;
white-space: nowrap;
}
.slider-demo-block .demonstration + .el-slider {
flex: 0 0 70%;
}
</style>
24 changes: 24 additions & 0 deletions src/views/components/slider/components/Vertical.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { ref } from "vue";
const value = ref(0);
</script>

<template>
<div class="slider-demo-block">
<el-slider v-model="value" vertical height="200px" />
</div>
</template>

<style lang="scss" scoped>
.slider-demo-block {
display: flex;
align-items: center;
max-width: 600px;
}
.slider-demo-block .el-slider {
margin-top: 0;
margin-left: 12px;
}
</style>
8 changes: 8 additions & 0 deletions src/views/components/slider/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export { default as Base } from "./Base.vue";
export { default as Step } from "./Step.vue";
export { default as Size } from "./Size.vue";
export { default as Input } from "./Input.vue";
export { default as Range } from "./Range.vue";
export { default as Marks } from "./Marks.vue";
export { default as Vertical } from "./Vertical.vue";
export { default as Placement } from "./Placement.vue";
Loading

0 comments on commit bbdd44a

Please sign in to comment.