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
47 changes: 33 additions & 14 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import commonjs from 'rollup-plugin-commonjs'
import copy from 'rollup-plugin-copy'
import { terser } from 'rollup-plugin-terser'
import del from 'rollup-plugin-delete'
import multiInput from 'rollup-plugin-multi-input'

const external = [
...Object.keys(pkg.dependencies || {}),
Expand All @@ -15,20 +16,23 @@ const external = [
]

export default {
input: 'src/index.ts',
output: [
{
name: 'SoramitsuJsUi',
file: 'lib/soramitsu-js-ui.esm.js',
format: 'esm',
sourcemap: true
}, {
name: 'SoramitsuJsUiUmd',
format: 'umd',
file: 'lib/soramitsu-js-ui.umd.js',
sourcemap: true
}
input: [
'src/index.ts',
'src/types/DesignSystem.ts',
'src/types/Locale.ts',
'src/types/Theme.ts',
'src/locale/index.ts',
'src/plugins/*.ts',
'src/store/index.ts',
'src/utils/*.ts',
'src/directives/index.ts',
'src/components/*/**/index.ts'
],
output: {
format: 'esm',
dir: 'lib'
// sourcemap: true We don't need it because of d.ts files
},
external (id) {
return external.includes(id.split('/')[0]) ||
/element-ui\/lib\//.test(id)
Expand All @@ -52,6 +56,9 @@ export default {
{ src: 'src/styles/neumorphism/*', dest: 'lib/styles/neumorphism' }
]
}),
multiInput({
relative: 'src/'
}),
typescript({
typescript: require('typescript'),
objectHashIgnoreUnknownHack: true,
Expand All @@ -69,7 +76,19 @@ export default {
resolve(),
terser(),
del({
targets: ['lib/styles/index.d.ts', 'lib/soramitsu-js-ui.esm.css'],
targets: [
'lib/styles/index.d.ts',
'bundle.css'
// TODO: find a way how to remove this dependencies
// 'lib/BorderRadiusMixin-**.js',
// 'lib/SizeMixin-**.js',
// 'lib/DesignSystem-**.js',
// 'lib/DesignSystemInject-**.js',
// 'lib/normalize-component-**.js',
// 'lib/components-**.js',
// 'lib/consts-**.js',
// 'lib/index-**.js'
],
hook: 'writeBundle'
})
]
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@soramitsu/soramitsu-js-ui",
"version": "1.0.2",
"version": "1.0.3",
"private": false,
"publishConfig": {
"registry": "https://nexus.iroha.tech/repository/npm-soramitsu/"
Expand All @@ -13,9 +13,9 @@
}
],
"author": "Stefan Popov <popov@soramitsu.co.jp>",
"main": "./lib/soramitsu-js-ui.umd.js",
"module": "./lib/soramitsu-js-ui.esm.js",
"unpkg": "./lib/soramitsu-js-ui.min.js",
"main": "./lib/index.js",
"module": "./lib/index.js",
"unpkg": "./lib/index.js",
"typings": "./lib/index.d.ts",
"scripts": {
"build": "rm -rf lib && rollup -c ./build/rollup.config.js",
Expand Down Expand Up @@ -75,6 +75,7 @@
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-delete": "^1.1.0",
"rollup-plugin-multi-input": "^1.3.1",
"rollup-plugin-scss": "^2.5.0",
"rollup-plugin-terser": "^5.1.2",
"rollup-plugin-typescript2": "^0.25.2",
Expand All @@ -94,7 +95,6 @@
},
"files": [
"lib/*",
"src/*",
"*.json",
"*.js"
],
Expand Down
3 changes: 0 additions & 3 deletions src/components/Card/SCard/SCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import BorderRadiusMixin from '../../../mixins/BorderRadiusMixin'
import SizeMixin from '../../../mixins/SizeMixin'
import StatusMixin from '../../../mixins/StatusMixin'
import { CardShadow } from '../consts'
import { BorderRadius } from '../../../types'

@Component({
components: { ElCard }
Expand Down Expand Up @@ -48,8 +47,6 @@ export default class SCard extends Mixins(BorderRadiusMixin, SizeMixin, StatusMi
* `false` by default
*/
@Prop({ default: false, type: Boolean }) readonly clickable!: boolean

@Prop({ default: BorderRadius.MEDIUM }) borderRadius!: string
/**
* Does card should looks like it's under surface (inner shadow)
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/DesignSystem/DesignSystemInject.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Vue, Inject, Prop } from 'vue-property-decorator'
import { DesignSystemProvideKey } from './consts'
import { DesignSystem } from '../../utils/DesignSystem'
import DesignSystem from '../../types/DesignSystem'

@Component
export default class DesignSystemInject extends Vue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script lang="ts">
import { Component, Vue, Prop, Provide, Watch } from 'vue-property-decorator'
import { DesignSystemProvideKey } from '../consts'
import { DesignSystem } from '../../../utils/DesignSystem'
import DesignSystem from '../../../types/DesignSystem'

@Component
export default class SDesignSystemProvider extends Vue {
Expand Down
5 changes: 0 additions & 5 deletions src/components/DesignSystem/consts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
export const DesignSystemProvideKey = 'designSystem'

export enum DesignSystem {
DEFAULT = '',
NEUMORPHIC = 'neumorphic'
}
1 change: 1 addition & 0 deletions src/components/Switch/SSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<script lang="ts">
import { Mixins, Component, Prop, Watch } from 'vue-property-decorator'
import ElSwitch from 'element-ui/lib/switch'

import DesignSystemInject from '../DesignSystem/DesignSystemInject'

@Component({
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tooltip/STooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import ElTooltip from 'element-ui/lib/tooltip'

import DesignSystemInject from '../DesignSystem/DesignSystemInject'
import BorderRadiusMixin from '../../mixins/BorderRadiusMixin'
import { Theme } from '../../utils/Theme'
import Theme from '../../types/Theme'
import { TooltipTheme, TooltipPlacement } from './consts'

@Component({
Expand Down
2 changes: 1 addition & 1 deletion src/directives/number.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DirectiveOptions } from 'vue'

import { KeyValues } from '../utils/KeyValues'
import KeyValues from '../utils/KeyValues'

const onDigitKeyPress = (e: any) => {
if (!KeyValues.isDigit(e.key)) {
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ import { Float, Integer } from './directives'
import { Components } from './types/components'
import { Directives } from './types/directives'
import { setTheme, setDesignSystem, setLocale } from './utils'
import { DesignSystem } from './utils/DesignSystem'
import { Theme } from './utils/Theme'
import { Locale } from './utils/Locale'
import DesignSystem from './types/DesignSystem'
import Theme from './types/Theme'
import Locale from './types/Locale'
import { SoramitsuUIStorePlugin, ElementUIPlugin } from './plugins'
import { Loading, Message, MessageBox, Notification } from './plugins/elementUI'
import { SDialogMixin } from './mixins'
Expand Down
2 changes: 1 addition & 1 deletion src/locale/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Vue from 'vue'
import VueI18n from 'vue-i18n'

import { Locale } from '../utils/Locale'
import Locale from '../types/Locale'

import en from './en'
import ja from './ja'
Expand Down
2 changes: 1 addition & 1 deletion src/store/LibraryLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fromPairs from 'lodash/fp/fromPairs'
import flow from 'lodash/fp/flow'
import concat from 'lodash/fp/concat'

import { Locale } from '../utils/Locale'
import Locale from '../types/Locale'
import i18n from '../locale'

const types = flow(
Expand Down
12 changes: 6 additions & 6 deletions src/store/LibraryTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import fromPairs from 'lodash/fp/fromPairs'
import flow from 'lodash/fp/flow'
import concat from 'lodash/fp/concat'

import { Theme } from '../utils/Theme'
import { DesignSystem } from '../utils/DesignSystem'
import Theme from '../types/Theme'
import DesignSystem from '../types/DesignSystem'

const types = flow(
flatMap(x => [x + '_REQUEST', x + '_SUCCESS', x + '_FAILURE']),
concat([
'CHANGE_THEME',
'SET_THEME',
'SET_DESIGN_SYSTEM'
]),
map(x => [x, x]),
Expand Down Expand Up @@ -41,7 +41,7 @@ const getters = {
}

const mutations = {
[types.CHANGE_THEME] (state: State, theme: Theme) {
[types.SET_THEME] (state: State, theme: Theme) {
state.theme = theme
},
[types.SET_DESIGN_SYSTEM] (state: State, designSystem: DesignSystem) {
Expand All @@ -50,8 +50,8 @@ const mutations = {
}

const actions = {
changeTheme ({ commit }, { theme }) {
commit(types.CHANGE_THEME, theme)
setTheme ({ commit }, theme: Theme) {
commit(types.SET_THEME, theme)
},
setDesignSystem ({ commit }, designSystem: DesignSystem) {
commit(types.SET_DESIGN_SYSTEM, designSystem)
Expand Down
2 changes: 1 addition & 1 deletion src/stories/Collapse/SCollapse.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { withKnobs, boolean, select } from '@storybook/addon-knobs'

import { SCollapse, SCollapseItem, SDesignSystemProvider } from '../../components'
import { BorderTypes } from '../../components/Collapse'
import { DesignSystem } from '../../utils/DesignSystem'
import DesignSystem from '../../types/DesignSystem'

export default {
component: SCollapse,
Expand Down
57 changes: 51 additions & 6 deletions src/stories/Intro/Intro.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,70 @@ For instance, `soramitsuUI.ts`:

```
import Vue from 'vue'
import SoramitsuElements, { Message, MessageBox, Notification } from '@soramitsu/soramitsu-js-ui'
import '@soramitsu/soramitsu-js-ui/lib/styles'

Vue.use(SoramitsuElements)
import SoramitsuElements, {
Message,
MessageBox,
Notification,
setTheme,
setDesignSystem,
Theme,
DesignSystem
} from '@soramitsu/soramitsu-js-ui'

import store from '@/store'

Vue.use(SoramitsuElements, { store })
Vue.prototype.$prompt = MessageBox.prompt
Vue.prototype.$alert = MessageBox.alert
Vue.prototype.$message = Message
Vue.prototype.$notify = Notification

setTheme(Theme.LIGHT)
setDesignSystem(DesignSystem.NEUMORPHIC)
```

You could also use direct components import:

```
import Vue from 'vue'

import Theme from '@soramitsu/soramitsu-js-ui/lib/types/Theme'
import DesignSystem from '@soramitsu/soramitsu-js-ui/lib/types/DesignSystem'
import { setTheme, setDesignSystem } from '@soramitsu/soramitsu-js-ui/lib/utils'

import ElementUIPlugin, { Message, MessageBox, Notification } from '@soramitsu/soramitsu-js-ui/lib/plugins/elementUI'
import SoramitsuUIStorePlugin from '@soramitsu/soramitsu-js-ui/lib/plugins/soramitsuUIStore'

import SButton from '@soramitsu/soramitsu-js-ui/lib/components/Button/SButton'

import store from '@/store'

Vue.use(ElementUIPlugin)
Vue.use(SoramitsuUIStorePlugin, { store })
Vue.use(SButton)

Vue.prototype.$prompt = MessageBox.prompt
Vue.prototype.$alert = MessageBox.alert
Vue.prototype.$message = Message
Vue.prototype.$notify = Notification

setTheme(Theme.LIGHT)
setDesignSystem(DesignSystem.NEUMORPHIC)
```

# 4. Add all required styles
# 4. Add element-ui types

Add `"element-ui"` in `tsconfig.json` file (`"types"` section)

# 5. Add all required styles

The previous section added not all required styles. To fix it you should add imports into `scss` file.

For instance, `soramitsu-variables.scss`:

```
@import '../../node_modules/@soramitsu/soramitsu-js-ui/lib/styles/index';
@import '~@soramitsu/soramitsu-js-ui/lib/styles/index';
```

If you want to customise some colors, borders, paddings, size, etc. - you can override scss variables.
Expand All @@ -65,6 +110,6 @@ $s-color-theme-accent: #ED145B;
// Basic colors
$s-color-base-content-primary: #0D0248;

@import '../../node_modules/@soramitsu/soramitsu-js-ui/lib/styles/index';
@import '~@soramitsu/soramitsu-js-ui/lib/styles/index';

```
4 changes: 2 additions & 2 deletions src/stories/SButton.stories.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { text, boolean, select, withKnobs } from '@storybook/addon-knobs'

import { SButton, SButtonGroup, SRow, SCol, SMain, SIcon, SDesignSystemProvider } from '../components'
import { Size, BorderRadius } from '../types'
import { ButtonTypes, ButtonIconPosition } from '../components/Button'
import { DesignSystem } from '../utils/DesignSystem'
import { Size, BorderRadius } from '../types'
import DesignSystem from '../types/DesignSystem'

export default {
component: SButton,
Expand Down
4 changes: 2 additions & 2 deletions src/stories/SCard.stories.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { text, withKnobs, select, boolean } from '@storybook/addon-knobs'

import { SCard, SRow, SDropdown, SDropdownItem, SDesignSystemProvider } from '../components'
import { BorderRadius, Status, Size } from '../types'
import { CardShadow } from '../components/Card'
import { DesignSystem } from '../utils/DesignSystem'
import { BorderRadius, Status, Size } from '../types'
import DesignSystem from '../types/DesignSystem'

export default {
component: SCard,
Expand Down
2 changes: 1 addition & 1 deletion src/stories/SDialog.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { text, withKnobs, boolean, select } from '@storybook/addon-knobs'

import { SDialog, SRow, SButton, SDesignSystemProvider } from '../components'
import { BorderRadius } from '../types'
import { DesignSystem } from '../utils/DesignSystem'
import DesignSystem from '../types/DesignSystem'

export default {
component: SDialog,
Expand Down
2 changes: 1 addition & 1 deletion src/stories/SFloatInput.stories.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { number, text, boolean, object, select, withKnobs } from '@storybook/addon-knobs'

import { SFloatInput, SRow, SDesignSystemProvider } from '../components'
import { DesignSystem } from '../utils/DesignSystem'
import DesignSystem from '../types/DesignSystem'

export default {
component: SFloatInput,
Expand Down
4 changes: 2 additions & 2 deletions src/stories/SInput.stories.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { text, boolean, withKnobs, number, select } from '@storybook/addon-knobs'

import { SInput, SRow, SCol, SDesignSystemProvider } from '../components'
import { BorderRadius } from '../types'
import { InputType, InputSize } from '../components/Input'
import { DesignSystem } from '../utils/DesignSystem'
import { BorderRadius } from '../types'
import DesignSystem from '../types/DesignSystem'

export default {
component: SInput,
Expand Down
Loading