Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@soramitsu/soramitsu-js-ui",
"version": "1.0.7",
"version": "1.0.8",
"private": false,
"publishConfig": {
"registry": "https://nexus.iroha.tech/repository/npm-soramitsu/"
Expand Down
7 changes: 7 additions & 0 deletions src/store/LibraryTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const types = flow(
flatMap(x => [x + '_REQUEST', x + '_SUCCESS', x + '_FAILURE']),
concat([
'SET_THEME',
'SWITCH_THEME',
'SET_DESIGN_SYSTEM'
]),
map(x => [x, x]),
Expand Down Expand Up @@ -46,6 +47,7 @@ const mutations = {
state.theme = theme
localStorage.setItem('libraryTheme', theme)
},
[types.SWITCH_THEME] (state: State) {},
[types.SET_DESIGN_SYSTEM] (state: State, designSystem: DesignSystem) {
state.designSystem = designSystem
}
Expand All @@ -59,6 +61,11 @@ const actions = {
}
document.documentElement.setAttribute('design-system-theme', computedTheme)
},
async switchTheme ({ commit, state: { theme }, dispatch }) {
const newTheme = theme === Theme.LIGHT ? Theme.DARK : Theme.LIGHT
commit(types.SWITCH_THEME)
await dispatch('setTheme', newTheme)
},
setDesignSystem ({ commit }, designSystem: DesignSystem) {
commit(types.SET_DESIGN_SYSTEM, designSystem)
}
Expand Down
4 changes: 4 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export const setTheme = async (theme?: Theme) => {
await store.dispatch('setTheme', theme)
}

export const switchTheme = async () => {
await store.dispatch('switchTheme')
}

export const setDesignSystem = async (designSystem: DesignSystem) => {
await store.dispatch('setDesignSystem', designSystem)
}
Expand Down