-
Notifications
You must be signed in to change notification settings - Fork 310
feat(config-provider): config-provider adds theme configuration function #3353
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<template> | ||
<tiny-tabs v-model="activeName" class="select-none" :optimized="false" swipeable> | ||
<tiny-tab-item title="表单组件" name="first"> | ||
<div class="flex w-fit"> | ||
<div class="bg-color-bg-1 w-96 h-60 mr-4"> | ||
表单组件,具有与用户交互,并可完成数据采集功能的控件。--tab 1 item 1 | ||
</div> | ||
<div class="bg-color-bg-2 w-96 h-60 mr-4"> | ||
表单组件,具有与用户交互,并可完成数据采集功能的控件。--tab 1 item 2 | ||
</div> | ||
<div class="bg-color-bg-3 w-96 h-60 mr-4"> | ||
表单组件,具有与用户交互,并可完成数据采集功能的控件。--tab 1 item 3 | ||
</div> | ||
<div class="bg-color-bg-4 w-96 h-60 mr-4"> | ||
表单组件,具有与用户交互,并可完成数据采集功能的控件。--tab 1 item 4 | ||
</div> | ||
<div class="bg-color-bg-5 w-96 h-60 mr-4"> | ||
表单组件,具有与用户交互,并可完成数据采集功能的控件。--tab 1 item 5 | ||
</div> | ||
</div> | ||
</tiny-tab-item> | ||
<tiny-tab-item title="数据组件" name="second"> | ||
<div class="bg-color-bg-6 w-full h-60 mr-4"> | ||
数据组件,提供了非常强大数据表格功能,在Grid可以展示数据列表,可以对数据列表进行选择、编辑等。--tab 2 | ||
</div> | ||
</tiny-tab-item> | ||
<tiny-tab-item title="导航组件" name="third"> | ||
<div class="bg-color-bg-7 w-full h-60 mr-4">导航组件,帮助网站访问者浏览站点的组件。--tab 3</div> | ||
</tiny-tab-item> | ||
<tiny-tab-item title="业务组件" name="fourth"> | ||
<div class="bg-color-bg-8 w-full h-60 mr-4">业务组件,与业务紧密相关实现某种业务功能的组件集。--tab 4</div> | ||
</tiny-tab-item> | ||
</tiny-tabs> | ||
</template> | ||
|
||
<script> | ||
import { TinyTabs, TinyTabItem } from '@opentiny/vue' | ||
|
||
export default { | ||
components: { | ||
TinyTabs, | ||
TinyTabItem | ||
}, | ||
data() { | ||
return { | ||
activeName: 'first' | ||
} | ||
} | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<template> | ||
<div> | ||
<tiny-button @click="changeTheme" style="margin-bottom: 20px">改变主题颜色</tiny-button> | ||
<tiny-button type="success" @click="resetTheme" style="margin-bottom: 20px">重置主题颜色</tiny-button> | ||
<tiny-config-provider :theme="theme"> | ||
<tiny-button type="primary">主题色按钮</tiny-button> | ||
</tiny-config-provider> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue' | ||
import { TinyConfigProvider, TinyButton } from '@opentiny/vue' | ||
|
||
const theme = ref({ | ||
data: {} | ||
}) | ||
|
||
function changeTheme() { | ||
theme.value = { | ||
data: { | ||
'tv-base-color-brand': 'green' | ||
} | ||
} | ||
} | ||
|
||
function resetTheme() { | ||
theme.value = { | ||
data: { | ||
'tv-base-color-brand': '#191919' | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.tiny-config-provider { | ||
padding: 1em; | ||
border: 1px solid #ccc; | ||
border-radius: 1em; | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<div> | ||
<tiny-button @click="changeTheme" style="margin-bottom: 20px">改变主题颜色</tiny-button> | ||
<tiny-button type="success" @click="resetTheme" style="margin-bottom: 20px">重置主题颜色</tiny-button> | ||
<tiny-config-provider :theme="theme"> | ||
<tiny-button type="primary">主题色按钮</tiny-button> | ||
</tiny-config-provider> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { TinyConfigProvider, TinyButton } from '@opentiny/vue' | ||
|
||
export default { | ||
components: { | ||
TinyConfigProvider, | ||
TinyButton | ||
}, | ||
data() { | ||
return { | ||
theme: { | ||
data: {} | ||
} | ||
} | ||
}, | ||
methods: { | ||
changeTheme() { | ||
this.theme = { | ||
data: { | ||
'tv-base-color-brand': 'green' | ||
} | ||
} | ||
}, | ||
resetTheme() { | ||
this.theme = { | ||
data: { | ||
'tv-base-color-brand': '#191919' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.tiny-config-provider { | ||
padding: 1em; | ||
border: 1px solid #ccc; | ||
border-radius: 1em; | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -20,4 +20,5 @@ export interface ConfigProviderProps { | |||||||||||||||||||||||||||||||||
enable?: boolean | ||||||||||||||||||||||||||||||||||
name?: string | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
theme?: Object | null | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid using Using + export interface ThemeConfig {
+ data: Record<string, string>;
+ // Add any other expected properties
+ }
export interface ConfigProviderProps {
breakPoints: breakPoint
direction: 'rtl' | 'ltr'
globalPrefix?: string
tag: {
enable?: boolean
name?: string
}
- theme?: Object | null
+ theme?: ThemeConfig | null
} 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 23-23: Don't use 'Object' as a type. Prefer explicitly define the object shape. This type means "any non-nullable value", which is slightly better than 'unknown', but it's still a broad type. (lint/complexity/noBannedTypes) |
||||||||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning message here should be more descriptive to guide the user on how to properly configure the
theme
property. Consider providing a more detailed example or linking to documentation.