Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
5 changes: 4 additions & 1 deletion src/stories/SButton.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
export const configurable = () => ({
components: { SButton, SIcon },
template: `<s-button
:class="typography"
:class="withTypography ? typography : ''"
:disabled="disabled"
:loading="loading"
:tooltip="tooltip"
Expand Down Expand Up @@ -60,6 +60,9 @@ export const configurable = () => ({
content: {
default: text('Button text', 'Default')
},
withTypography: {
default: boolean('With Typography css class', false)
},
typography: {
default: text('Typographic css class', 's-typography-button--large')
},
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