Skip to content

Commit 012bf89

Browse files
fix(vue): change approach to solve theme toggle issue
1 parent 50c04bd commit 012bf89

File tree

5 files changed

+1742
-1139
lines changed

5 files changed

+1742
-1139
lines changed

packages/vue/src/components/ReactiveBase/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ const ReactiveBase = {
275275
className={className}
276276
getSearchParams={this.getSearchParams}
277277
setSearchParams={this.setSearchParams}
278+
userThemeProp={this.$props.theme}
278279
>
279280
{children()}
280281
</URLParamsProvider>

packages/vue/src/components/URLParamsProvider.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const URLParamsProvider = {
1717
getSearchParams: types.func,
1818
setSearchParams: types.func,
1919
as: VueTypes.string.def('div'),
20+
userThemeProp: VueTypes.oneOf([VueTypes.bool, VueTypes.object.def({})]),
2021
},
2122
mounted() {
2223
this.init();
@@ -238,7 +239,11 @@ const URLParamsProvider = {
238239
render() {
239240
const children = this.$slots.default();
240241
return (
241-
<Base as={this.$props.as} class={this.$props.className}>
242+
<Base
243+
as={this.$props.as}
244+
class={this.$props.className}
245+
userThemeProp={this.$props.userThemeProp}
246+
>
242247
{children}
243248
</Base>
244249
);

packages/vue/src/styles/Base.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ const Base = ({
1313
};
1414

1515
export default styled(Base)`
16-
font-family: ${({ theme }) =>
17-
theme && theme.typography ? theme.typography.fontFamily : 'unset'};
18-
font-size: ${({ theme }) => (theme && theme.typography ? theme.typography.fontSize : 'unset')};
19-
color: ${({ theme }) => (theme && theme.colors ? theme.colors.textColor : 'unset')};
16+
${({ userThemeProp, theme }) =>
17+
userThemeProp === false
18+
? ''
19+
: `font-family: ${theme && theme.typography ? theme.typography.fontFamily : 'unset'};
20+
font-size: ${theme && theme.typography ? theme.typography.fontSize : 'unset'};
21+
color: ${theme && theme.colors ? theme.colors.textColor : 'unset'};`}
2022
width: 100%;
2123
2224
input,

packages/vue/src/utils/index.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,7 @@ export const X_SEARCH_CLIENT = 'ReactiveSearch Vue';
1717

1818
export const composeThemeObject = (ownTheme = {}, userThemeParam = {}) => {
1919
let userTheme = {};
20-
if (typeof userThemeParam === 'boolean' && userThemeParam === false) {
21-
userTheme = {
22-
typography: {
23-
fontFamily: 'inherit',
24-
fontSize: 'inherit',
25-
},
26-
colors: {
27-
textColor: 'inherit',
28-
primaryTextColor: 'inherit',
29-
primaryColor: 'inherit',
30-
titleColor: 'inherit',
31-
alertColor: 'inherit',
32-
borderColor: 'inherit',
33-
},
34-
};
35-
} else {
20+
if (typeof userThemeParam !== 'boolean' && Object.keys(userThemeParam).length) {
3621
userTheme = { ...userThemeParam };
3722
}
3823
return {

0 commit comments

Comments
 (0)