Skip to content

Commit

Permalink
Merge pull request #13 from kongying-tavern/refactor/new-ui
Browse files Browse the repository at this point in the history
New UI
  • Loading branch information
boxsnake authored Nov 29, 2023
2 parents f3e13aa + af2ae54 commit b50c442
Show file tree
Hide file tree
Showing 82 changed files with 1,175 additions and 579 deletions.
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"svgo": "svgo -rf src"
},
"dependencies": {
"@vueuse/core": "^10.1.2",
"element-plus": "^2.2.32",
"lodash": "^4.17.21",
"pinia": "^2.0.28",
Expand All @@ -28,29 +29,29 @@
"@rushstack/eslint-patch": "^1.1.4",
"@types/lodash": "^4.14.194",
"@types/node": "^18.11.12",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/eslint-plugin": "^6.13.0",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^11.0.0",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/tsconfig": "^0.1.3",
"autoprefixer": "^10.4.13",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.22.0",
"eslint-plugin-vue": "^9.3.0",
"postcss": "^8.4.21",
"prettier": "^2.7.1",
"eslint": "^8.54.0",
"eslint-plugin-vue": "^9.18.1",
"postcss": "^8.4.31",
"prettier": "^3.1.0",
"sass": "^1.58.3",
"semantic-release": "^20.1.3",
"stylelint": "^15.0.0",
"stylelint": "^15.11.0",
"stylelint-config-prettier": "^9.0.5",
"stylelint-config-sass-guidelines": "^9.0.1",
"stylelint-config-standard-scss": "^5.0.0",
"stylelint-prettier": "^3.0.0",
"stylelint-config-sass-guidelines": "^10.0.0",
"stylelint-config-standard-scss": "^11.1.0",
"stylelint-prettier": "^4.1.0",
"svgo": "^3.0.2",
"ts-keycode-enum": "^1.0.6",
"typescript": "~4.7.4",
"typescript": "^5.3.2",
"unplugin-auto-import": "^0.15.0",
"vite": "^4.0.0",
"vue-tsc": "^1.0.12"
Expand Down
11 changes: 11 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<script setup lang="ts">
import { useDark } from "@vueuse/core";
useDark({
selector: "body",
attribute: "data-theme",
valueDark: "dark",
valueLight: "light",
});
</script>

<template>
<RouterView />
</template>
57 changes: 35 additions & 22 deletions src/assets/effects/scrollbar.scss
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
@use 'sass:math';
@use '@/assets/vars/color.scss' as *;
@use "sass:math";
@use "@/assets/vars/color.scss" as *;
@use "./theme.scss";

$scrollbar-width: 0.4rem;
$scrollbar-radius: math.div($scrollbar-width, 2);
$scrollbar-color-track: $color-gray-4;
$scrollbar-color-thumb: $color-gray-3;
$scrollbar-colors-light: (
"scrollbar-track-color": $color-gray-4,
"scrollbar-thumb-color": $color-gray-3,
);
$scrollbar-colors-dark: (
"scrollbar-track-color": $color-gray-4,
"scrollbar-thumb-color": $color-gray-3,
);
$scrollbar-colors: (
light: $scrollbar-colors-light,
dark: $scrollbar-colors-dark,
);

@mixin scrollbar {
.scrollbar,
.scrollbar :deep(*) {
&::-webkit-scrollbar {
border-radius: $scrollbar-radius;
background-color: $scrollbar-color-track;
}
@include theme.themeify($scrollbar-colors) {
.scrollbar,
.scrollbar :deep(*) {
&::-webkit-scrollbar {
border-radius: $scrollbar-radius;
background-color: theme.t("scrollbar-track-color");
}

&::-webkit-scrollbar:horizontal {
height: $scrollbar-width;
}
&::-webkit-scrollbar:horizontal {
height: $scrollbar-width;
}

&::-webkit-scrollbar:vertical {
width: $scrollbar-width;
}
&::-webkit-scrollbar:vertical {
width: $scrollbar-width;
}

&::-webkit-scrollbar-button {
display: none;
}
&::-webkit-scrollbar-button {
display: none;
}

&::-webkit-scrollbar-thumb {
border-radius: $scrollbar-radius;
background-color: $scrollbar-color-thumb;
&::-webkit-scrollbar-thumb {
border-radius: $scrollbar-radius;
background-color: theme.t("scrollbar-thumb-color");
}
}
}
}
20 changes: 18 additions & 2 deletions src/assets/effects/shadow.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
@use "@/assets/vars/color.scss" as *;
@use "./theme.scss";

$shadow-colors-light: (
shadow-color: rgb(0 0 0 / 10%),
);
$shadow-colors-dark: (
shadow-color: rgb(0 0 0 / 10%),
);
$shadow-colors: (
light: $shadow-colors-light,
dark: $shadow-colors-dark,
);

@mixin box-shadow {
.box-shadow {
box-shadow: 0.3rem 0.3rem 0.36rem 0.04rem rgb(0 0 0 / 10%);
@include theme.themeify($shadow-colors) {
.box-shadow {
box-shadow: 0.3rem 0.3rem 0.36rem 0.04rem theme.t("shadow-color");
}
}
}
13 changes: 13 additions & 0 deletions src/assets/effects/theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@mixin themeify($themes) {
@each $theme-name, $theme-map in $themes {
$theme-map: $theme-map !global;

body[data-theme="#{$theme-name}"] {
@content;
}
}
}

@function t($key) {
@return map-get($theme-map, $key);
}
15 changes: 15 additions & 0 deletions src/assets/effects/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { get } from "lodash";
import { useGlobalSettings } from "@/hooks";

const { globalSettings } = useGlobalSettings();

type ThemeColorExportMap = { [key: string]: string };

export const getThemeColor = (
colorMap: ThemeColorExportMap,
colorKey: string,
) => {
const themeColorKey = `${globalSettings.value.theme || ""}--${colorKey}`;
const themeColorVal: string = get(colorMap, themeColorKey);
return themeColorVal;
};
6 changes: 3 additions & 3 deletions src/assets/style/app.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

:root {
font-size: 10px !important;
Expand Down
9 changes: 5 additions & 4 deletions src/assets/vars/color.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
$color-bg: #e6ecf2;
$color-white: #fff;
$color-primary-1: #66b3ff;
$color-primary-2: #39f;
$color-white-1: #fff;
$color-blue-1: #e6ecf2;
$color-blue-2: #66b3ff;
$color-blue-3: #39f;
$color-gray-1: #737980;
$color-gray-2: #808080;
$color-gray-3: #b3b3b3;
$color-gray-4: #f2f2f2;
$color-gray-5: #666;
$color-gray-6: #ccc;
$color-gray-7: #999;
105 changes: 0 additions & 105 deletions src/components/ButtonBasic.vue

This file was deleted.

76 changes: 76 additions & 0 deletions src/components/ButtonBasic/ButtonBasic.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<script setup lang="ts">
type ButtonSize = "large" | "medium" | "small";
type ButtonType = "default" | "primary";
interface Props {
clickable?: boolean;
size?: ButtonSize;
type?: ButtonType;
}
const emits = defineEmits<{
(e: "click"): void;
}>();
const props = withDefaults(defineProps<Props>(), {
clickable: true,
size: "medium",
type: "default",
});
const onClick = () => {
if (props.clickable) {
emits("click");
}
};
</script>

<template>
<div
class="btn-wrapper box-shadow"
:class="{
'cursor-pointer': clickable,
[`size-${props.size}`]: true,
[`type-${props.type}`]: true,
}"
@click="onClick()"
>
<slot></slot>
</div>
</template>

<style scoped lang="scss">
@use "@/assets/effects/theme.scss";
@use "./dim.scss" as *;
@use "./color.scss" as *;
@use "@/assets/effects/shadow.scss";
@include shadow.box-shadow;
$btn-size-names: ("small", "medium", "large");
$btn-type-names: ("default", "primary");
@include theme.themeify($btn-colors) {
.btn-wrapper {
display: inline-block;
font-size: $btn-font-size;
line-height: $btn-line-height;
text-align: center;
border-radius: $btn-corner-radius;
// Size Variants
@each $size-name in $btn-size-names {
&.size-#{$size-name} {
padding: map-get($btn-padding, $size-name);
}
}
// Color Variants
@each $type-name in $btn-type-names {
&.type-#{$type-name} {
background-color: theme.t("btn-#{$type-name}-fill-color");
color: theme.t("btn-#{$type-name}-text-color");
}
}
}
}
</style>
Loading

0 comments on commit b50c442

Please sign in to comment.