Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add light mode and dark mode.(#89) #105

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ module.exports = {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
"vue/multi-word-component-names": "off"
},
};
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"less-loader": "^11.1.3",
"open-im-sdk-wasm": "^0.1.1",
"qs": "^6.11.2",
"tdesign-icons-vue-next": "^0.1.11",
"tdesign-vue-next": "^1.3.10",
"vite-svg-loader": "^4.0.0",
"vue": "^3.3.4",
Expand Down
2 changes: 1 addition & 1 deletion web/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const routes = [
{
path: '/login',
name: 'Login',
component: () => import('@/views/login/LoginIndex.vue'),
component: () => import('@/views/login/index.vue'),
},
];

Expand Down
15 changes: 14 additions & 1 deletion web/src/views/login/components/LoginHeader.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { ref } from "vue";
import { CloseIcon, CheckIcon } from 'tdesign-icons-vue-next';
import OpenKFLogo from '@/assets/openkf-logo.svg?component';

const navToGitHub = () => {
Expand All @@ -8,6 +10,16 @@ const navToGitHub = () => {
const navToDoc = () => {
window.open('https://openkf.github.io/website/');
};

const darkMode = ref(false);
const emit = defineEmits<{
(e: 'changeMode', value: boolean): void
}>();

const changeModeAction = () => {
emit('changeMode', darkMode.value);
};

</script>

<template>
Expand All @@ -34,6 +46,7 @@ const navToDoc = () => {
<t-icon name="help-circle-filled" class="icon" />
</t-button>
<!-- Add theme tabs -->
<t-switch v-model="darkMode" size="small" @change="changeModeAction"></t-switch>
</div>
</header>
</template>
Expand Down Expand Up @@ -74,7 +87,7 @@ const navToDoc = () => {
.operations-container {
display: flex;
align-items: center;
.t-button {
.t-button, .t-switch {
margin-left: var(--td-comp-margin-l);
}
}
Expand Down
4 changes: 3 additions & 1 deletion web/src/views/login/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

.sub-title {
margin-top: var(--td-comp-margin-xxl);
color: var(--td-text-color-primary);

.tip {
display: inline-block;
Expand Down Expand Up @@ -87,7 +88,8 @@
}

span {
color: var(--td-brand-color);
color: var(--td-text-color-primary);
font-weight: 500;

&:hover {
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,26 @@ import RegisterForm from './components/RegisterForm.vue';
import { ref } from 'vue';

const type = ref('login');
const isDark = ref(false);

const switchType = (val: string) => {
type.value = val;
};
const changeMode = (value: boolean) => {
console.log(value);
isDark.value = value
if (isDark.value) {
document.documentElement.setAttribute('theme-mode', 'dark');
} else {
document.documentElement.setAttribute('theme-mode', 'light');
}
}

</script>

<template>
<div class="login-wrapper">
<login-header />
<div :class="[isDark ? 'dark' : 'light', 'login-wrapper']">
<login-header @change-mode="changeMode"/>

<div class="login-container">
<div class="title-container">
Expand Down