mediacube-ui 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediacube-ui",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Design system for MediaCube services",
5
5
  "author": "MediaCube",
6
6
  "private": false,
@@ -17,7 +17,8 @@
17
17
  "src/tokens/*",
18
18
  "src/elements/**/*.vue",
19
19
  "src/patterns/**/*.vue",
20
- "src/templates/**/*.vue"
20
+ "src/templates/**/*.vue",
21
+ "src/utils/*"
21
22
  ],
22
23
  "scripts": {
23
24
  "start": "yarn scss-export && start-storybook -p 6006 -s public",
@@ -0,0 +1,11 @@
1
+ import numeral from "numeral"
2
+
3
+ export const number = (value, decimals = 2) => {
4
+ if (value == null) return null
5
+
6
+ let deciamlsString = "".padStart(decimals, "0")
7
+
8
+ return numeral(value)
9
+ .format("0,0." + deciamlsString)
10
+ .replace(/,/g, " ")
11
+ }
@@ -0,0 +1,41 @@
1
+ import tokens from '../assets/tokens/tokens.json'
2
+
3
+ const getTokenValue = name => {
4
+ const tokenData = tokens.variables.find(v => v.name === name)
5
+ return tokenData.value
6
+ }
7
+
8
+ const getTokensByType = type => {
9
+ const filteredTokens = tokens.variables.filter(v => {
10
+ const regExp = new RegExp(`^\\$${type}-`)
11
+ return regExp.test(v.name)
12
+ })
13
+ const tokenList = {}
14
+ filteredTokens.forEach(t => {
15
+ const key = t.name.replace(`$${type}-`, '')
16
+ tokenList[key] = key
17
+ })
18
+ return tokenList
19
+ }
20
+
21
+ const getTokenGroup = name => {
22
+ const dataTokens = tokens.variables.find(v => v.name === `$token-${name}`)
23
+ let tokenList = {}
24
+ if (!dataTokens) return tokenList
25
+
26
+ if ('mapValue' in dataTokens) {
27
+ dataTokens.mapValue.forEach(t => (tokenList[t.name] = t.name))
28
+ return tokenList
29
+ }
30
+
31
+ const valueArr = dataTokens.value.replace(/\/\*.+\*\/\s/, '').split(' ')
32
+ valueArr.forEach(i => {
33
+ if (i.match(/.+:$/)) {
34
+ const key = i.slice(0, i.length - 1)
35
+ tokenList[key] = key
36
+ }
37
+ })
38
+ return tokenList
39
+ }
40
+
41
+ export { getTokensByType, getTokenGroup, getTokenValue }
@@ -0,0 +1,3 @@
1
+ const svgIconsReq = require.context('!!raw-loader!../assets/icons', true, /.\.svg$/)
2
+ const svgIcons = svgIconsReq.keys().map(name => ({ name, content: svgIconsReq(name).default }))
3
+ export default svgIcons
@@ -0,0 +1,30 @@
1
+ export const findParentComponent = ($component, name) => {
2
+ let $parent = null
3
+ do {
4
+ if (!$component) {
5
+ return null
6
+ }
7
+ let $componentParent = $component.$parent
8
+ if ($componentParent && $componentParent.$options.name === name) {
9
+ $parent = $componentParent
10
+ } else {
11
+ $component = $componentParent
12
+ }
13
+ } while ($parent == null)
14
+ return $parent
15
+ }
16
+
17
+ export const findChildrenComponents = ($component, name) => {
18
+ if ($component.$children == null || $component.$children.length === 0) return []
19
+
20
+ let $collapses = []
21
+ $component.$children.forEach($child => {
22
+ if ($child.$options.name === name) {
23
+ $collapses = [...$collapses, $child]
24
+ } else {
25
+ $collapses = [...$collapses, ...findChildrenComponents($child, name)]
26
+ }
27
+ })
28
+
29
+ return $collapses
30
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Web Font Loader takes care of Vue Design System’s font loading.
3
+ * For full documentation, see: https://github.com/typekit/webfontloader
4
+ */
5
+ import WebFont from 'webfontloader'
6
+
7
+ WebFont.load({
8
+ custom: {
9
+ families: ['Font Awesome 5 Icons:400,900', 'Font Awesome 5 Brands:400'],
10
+ urls: ['https://maxst.icons8.com/vue-static/landings/line-awesome/line-awesome/1.3.0/css/line-awesome.min.css'],
11
+ },
12
+ })