diff --git a/README.md b/README.md index 003b27c4..695a8a05 100644 --- a/README.md +++ b/README.md @@ -14,19 +14,30 @@ $s-font-family-mono-path: '~@soramitsu/soramitsu-js-ui/lib/assets/fonts/JetBrain $s-font-family-icons-path: '~@soramitsu/soramitsu-js-ui/lib/assets/fonts/soramitsu-icons-1.0.0.ttf' !default; ``` -## Custom components, directives setup -Import "Components" enum from library, and pass the list of needed components to SoramitsuElements options +## Usage library in project +### 1.Install all of library components: +``` +import Vue from 'vue +import SoramitsuElements from '@soramitsu/soramitsu-js-ui' -Note: Without customization all library components and directives are registering global +const options = { + store // if u want to merge ui lib modules +} +Vue.use(SoramitsuElements, options) +``` +### 2.Install only necessary components (to reduce vendors bundle size) ``` -import Vue from 'vue' -import SoramitsuElements, { Components, Directives } from '@soramitsu/soramitsu-js-ui' +import Vue from 'vue +import ElementUIPlugin from '@soramitsu/soramitsu-js-ui/src/plugins/elementUI' +import SoramitsuUIStorePlugin from '@soramitsu/soramitsu-js-ui/src/plugins/soramitsuUIStore' +import SButton from '@soramitsu/soramitsu-js-ui/src/components/Button/SButton' +import SButton from '@soramitsu/soramitsu-js-ui/src/components/Input/SInput' -Vue.use(SoramitsuElements, { - components: [Components.Button, Components.Input], - directives: [Directives.Float] -}) +Vue.use(ElementUIPlugin) // required +Vue.use(SoramitsuUIStorePlugin, store) // optional +Vue.use(SButton) +Vue.use(SInput) ``` ### Compiles and hot-reloads storybook with components for development diff --git a/config/storybook/preview.js b/config/storybook/preview.js index 32ea951b..9b3377df 100644 --- a/config/storybook/preview.js +++ b/config/storybook/preview.js @@ -1,8 +1,13 @@ +import Vue from 'vue' import { addParameters, addDecorator } from '@storybook/vue' import { withA11y } from '@storybook/addon-a11y' import { DocsPage } from '@storybook/addon-docs/blocks' +import '../../src/styles/index.scss' import mainStore from '../../src/store' +import { ElementUIPlugin } from '../../src/plugins' + +Vue.use(ElementUIPlugin) addParameters({ options: { diff --git a/package.json b/package.json index 403eaed7..2a4a4553 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@soramitsu/soramitsu-js-ui", - "version": "0.9.14", + "version": "0.9.15", "private": false, "publishConfig": { "registry": "https://nexus.iroha.tech/repository/npm-soramitsu/" @@ -27,8 +27,10 @@ }, "dependencies": { "core-js": "^3.6.4", + "element-resize-detector": "^1.2.1", "element-ui": "^2.13.2", "lodash": "^4.17.15", + "throttle-debounce": "^1.0.1", "v-jsoneditor": "^1.4.1", "vue": "^2.6.11", "vue-class-component": "^7.2.3", @@ -59,7 +61,6 @@ "@vue/eslint-config-standard": "^5.1.2", "@vue/eslint-config-typescript": "^5.0.2", "@vue/test-utils": "1.0.0-beta.31", - "element-resize-detector": "^1.2.1", "eslint": "^6.7.2", "eslint-plugin-import": "^2.20.2", "eslint-plugin-node": "^11.1.0", @@ -80,7 +81,6 @@ "rollup-plugin-vue": "^5.1.4", "sass-loader": "^8.0.2", "storybook-vue-router": "^1.0.7", - "throttle-debounce": "^1.0.1", "ts-jest": "^26.0.0", "typescript": "~3.8.3", "vue-cli-plugin-storybook": "~1.2.2", @@ -94,6 +94,7 @@ }, "files": [ "lib/*", + "src/*", "*.json", "*.js" ], @@ -101,6 +102,7 @@ "react": "16.13.0", "react-dom": "16.13.0" }, + "sideEffects": false, "gitHooks": { "pre-commit": "lint-staged" }, diff --git a/src/components/Breadcrumb/SBreadcrumb.vue b/src/components/Breadcrumb/SBreadcrumb/SBreadcrumb.vue similarity index 100% rename from src/components/Breadcrumb/SBreadcrumb.vue rename to src/components/Breadcrumb/SBreadcrumb/SBreadcrumb.vue diff --git a/src/components/Breadcrumb/SBreadcrumb/index.ts b/src/components/Breadcrumb/SBreadcrumb/index.ts new file mode 100644 index 00000000..25093ad7 --- /dev/null +++ b/src/components/Breadcrumb/SBreadcrumb/index.ts @@ -0,0 +1,13 @@ +import { VueConstructor } from 'vue' +import { Components, SFCWithInstall } from '../../../types/components' + +import _SBreadcrumb from './SBreadcrumb.vue' + +const SBreadcrumb = _SBreadcrumb as SFCWithInstall + +SBreadcrumb.install = function (vue: VueConstructor) { + vue.component(Components.SBreadcrumb, SBreadcrumb) +} + +export { SBreadcrumb } +export default SBreadcrumb diff --git a/src/components/Breadcrumb/SBreadcrumbItem.vue b/src/components/Breadcrumb/SBreadcrumbItem/SBreadcrumbItem.vue similarity index 100% rename from src/components/Breadcrumb/SBreadcrumbItem.vue rename to src/components/Breadcrumb/SBreadcrumbItem/SBreadcrumbItem.vue diff --git a/src/components/Breadcrumb/SBreadcrumbItem/index.ts b/src/components/Breadcrumb/SBreadcrumbItem/index.ts new file mode 100644 index 00000000..4b553cb2 --- /dev/null +++ b/src/components/Breadcrumb/SBreadcrumbItem/index.ts @@ -0,0 +1,13 @@ +import { VueConstructor } from 'vue' +import { Components, SFCWithInstall } from '../../../types/components' + +import _SBreadcrumbItem from './SBreadcrumbItem.vue' + +const SBreadcrumbItem = _SBreadcrumbItem as SFCWithInstall + +SBreadcrumbItem.install = function (vue: VueConstructor) { + vue.component(Components.SBreadcrumbItem, SBreadcrumbItem) +} + +export { SBreadcrumbItem } +export default SBreadcrumbItem diff --git a/src/components/Breadcrumb/index.ts b/src/components/Breadcrumb/index.ts index d1df7fdf..6a9f7826 100644 --- a/src/components/Breadcrumb/index.ts +++ b/src/components/Breadcrumb/index.ts @@ -1,4 +1,2 @@ -import SBreadcrumb from './SBreadcrumb.vue' -import SBreadcrumbItem from './SBreadcrumbItem.vue' - -export { SBreadcrumb, SBreadcrumbItem } +export { SBreadcrumb } from './SBreadcrumb' +export { SBreadcrumbItem } from './SBreadcrumbItem' diff --git a/src/components/Button/SButton.vue b/src/components/Button/SButton/SButton.vue similarity index 95% rename from src/components/Button/SButton.vue rename to src/components/Button/SButton/SButton.vue index f7daf048..c4bbd2cc 100644 --- a/src/components/Button/SButton.vue +++ b/src/components/Button/SButton/SButton.vue @@ -26,12 +26,12 @@ import { ElForm } from 'element-ui/types/form' import { ElFormItem } from 'element-ui/types/form-item' import { PopoverPlacement } from 'element-ui/types/popover' -import { DesignSystemInject } from '../DesignSystem' -import SizeMixin from '../../mixins/SizeMixin' -import BorderRadiusMixin from '../../mixins/BorderRadiusMixin' -import { SIcon } from '../Icon' -import { STooltip, TooltipPlacement } from '../Tooltip' -import { ButtonTypes, ButtonNativeTypes, ButtonIconPosition } from './consts' +import DesignSystemInject from '../../DesignSystem/DesignSystemInject' +import SizeMixin from '../../../mixins/SizeMixin' +import BorderRadiusMixin from '../../../mixins/BorderRadiusMixin' +import { SIcon } from '../../Icon/SIcon' +import { STooltip, TooltipPlacement } from '../../Tooltip' +import { ButtonTypes, ButtonNativeTypes, ButtonIconPosition } from '../consts' @Component({ components: { SIcon, STooltip } diff --git a/src/components/Button/SButton/index.ts b/src/components/Button/SButton/index.ts new file mode 100644 index 00000000..6e4b31ab --- /dev/null +++ b/src/components/Button/SButton/index.ts @@ -0,0 +1,13 @@ +import { VueConstructor } from 'vue' +import { Components, SFCWithInstall } from '../../../types/components' + +import _SButton from './SButton.vue' + +const SButton = _SButton as SFCWithInstall + +SButton.install = function (vue: VueConstructor) { + vue.component(Components.SButton, SButton) +} + +export { SButton } +export default SButton diff --git a/src/components/Button/SButtonGroup.vue b/src/components/Button/SButtonGroup/SButtonGroup.vue similarity index 100% rename from src/components/Button/SButtonGroup.vue rename to src/components/Button/SButtonGroup/SButtonGroup.vue diff --git a/src/components/Button/SButtonGroup/index.ts b/src/components/Button/SButtonGroup/index.ts new file mode 100644 index 00000000..1d5863b0 --- /dev/null +++ b/src/components/Button/SButtonGroup/index.ts @@ -0,0 +1,13 @@ +import { VueConstructor } from 'vue' +import { Components, SFCWithInstall } from '../../../types/components' + +import _SButtonGroup from './SButtonGroup.vue' + +const SButtonGroup = _SButtonGroup as SFCWithInstall + +SButtonGroup.install = function (vue: VueConstructor) { + vue.component(Components.SButtonGroup, SButtonGroup) +} + +export { SButtonGroup } +export default SButtonGroup diff --git a/src/components/Button/index.ts b/src/components/Button/index.ts index 9f6d31bc..c205d11f 100644 --- a/src/components/Button/index.ts +++ b/src/components/Button/index.ts @@ -1,11 +1,3 @@ -import SButton from './SButton.vue' -import SButtonGroup from './SButtonGroup.vue' -import { ButtonTypes, ButtonNativeTypes, ButtonIconPosition } from './consts' - -export { - SButton, - SButtonGroup, - ButtonTypes, - ButtonNativeTypes, - ButtonIconPosition -} +export { SButton } from './SButton' +export { SButtonGroup } from './SButtonGroup' +export { ButtonTypes, ButtonNativeTypes, ButtonIconPosition } from './consts' diff --git a/src/components/Card/SCard.vue b/src/components/Card/SCard/SCard.vue similarity index 87% rename from src/components/Card/SCard.vue rename to src/components/Card/SCard/SCard.vue index 3bb9b7e3..2f732b84 100644 --- a/src/components/Card/SCard.vue +++ b/src/components/Card/SCard/SCard.vue @@ -14,12 +14,12 @@ + + + diff --git a/src/components/Table/SHierarchicalTable/index.ts b/src/components/Table/SHierarchicalTable/index.ts new file mode 100644 index 00000000..f2a7de91 --- /dev/null +++ b/src/components/Table/SHierarchicalTable/index.ts @@ -0,0 +1,13 @@ +import { VueConstructor } from 'vue' +import { Components, SFCWithInstall } from '../../../types/components' + +import _SHierarchicalTable from './SHierarchicalTable.vue' + +const SHierarchicalTable = _SHierarchicalTable as SFCWithInstall + +SHierarchicalTable.install = function (vue: VueConstructor) { + vue.component(Components.SHierarchicalTable, SHierarchicalTable) +} + +export { SHierarchicalTable } +export default SHierarchicalTable diff --git a/src/components/Table/STable.vue b/src/components/Table/STable/STable.vue similarity index 98% rename from src/components/Table/STable.vue rename to src/components/Table/STable/STable.vue index fc249316..86f95f99 100644 --- a/src/components/Table/STable.vue +++ b/src/components/Table/STable/STable.vue @@ -63,9 +63,9 @@ import { Component, Mixins, Prop, Ref, Provide } from 'vue-property-decorator' import { ElTable } from 'element-ui/types/table' import { ElTableColumn } from 'element-ui/types/table-column' -import SizeMixin from '../../mixins/SizeMixin' -import { TooltipTheme } from '../Tooltip' -import { SortDirection } from './consts' +import SizeMixin from '../../../mixins/SizeMixin' +import { TooltipTheme } from '../../Tooltip/consts' +import { SortDirection } from '../consts' @Component export default class STable extends Mixins(SizeMixin) { diff --git a/src/components/Table/STable/index.ts b/src/components/Table/STable/index.ts new file mode 100644 index 00000000..21315cdb --- /dev/null +++ b/src/components/Table/STable/index.ts @@ -0,0 +1,13 @@ +import { VueConstructor } from 'vue' +import { Components, SFCWithInstall } from '../../../types/components' + +import _STable from './STable.vue' + +const STable = _STable as SFCWithInstall + +STable.install = function (vue: VueConstructor) { + vue.component(Components.STable, STable) +} + +export { STable } +export default STable diff --git a/src/components/Table/STableColumn.vue b/src/components/Table/STableColumn/STableColumn.vue similarity index 95% rename from src/components/Table/STableColumn.vue rename to src/components/Table/STableColumn/STableColumn.vue index 6de202dc..02901c93 100644 --- a/src/components/Table/STableColumn.vue +++ b/src/components/Table/STableColumn/STableColumn.vue @@ -1,205 +1,205 @@ - - - + + + diff --git a/src/components/Table/STableColumn/index.ts b/src/components/Table/STableColumn/index.ts new file mode 100644 index 00000000..2c85fd6a --- /dev/null +++ b/src/components/Table/STableColumn/index.ts @@ -0,0 +1,13 @@ +import { VueConstructor } from 'vue' +import { Components, SFCWithInstall } from '../../../types/components' + +import _STableColumn from './STableColumn.vue' + +const STableColumn = _STableColumn as SFCWithInstall + +STableColumn.install = function (vue: VueConstructor) { + vue.component(Components.STableColumn, STableColumn) +} + +export { STableColumn } +export default STableColumn diff --git a/src/components/Table/index.ts b/src/components/Table/index.ts index 402c3c3c..f62027ec 100644 --- a/src/components/Table/index.ts +++ b/src/components/Table/index.ts @@ -1,14 +1,4 @@ -import STable from './STable.vue' -import SHierarchicalTable from './SHierarchicalTable.vue' -import STableColumn from './STableColumn.vue' -import { ColumnAlignment, ColumnFixedPosition, ColumnType, SortDirection } from './consts' - -export { - STable, - SHierarchicalTable, - STableColumn, - ColumnAlignment, - ColumnFixedPosition, - ColumnType, - SortDirection -} +export { STable } from './STable' +export { SHierarchicalTable } from './SHierarchicalTable' +export { STableColumn } from './STableColumn' +export { ColumnAlignment, ColumnFixedPosition, ColumnType, SortDirection } from './consts' diff --git a/src/components/Tooltip/STooltip.vue b/src/components/Tooltip/STooltip.vue index df3f3692..d88d2e46 100644 --- a/src/components/Tooltip/STooltip.vue +++ b/src/components/Tooltip/STooltip.vue @@ -24,11 +24,10 @@