fleetcor-lwc 1.0.0

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/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # Fleetcor LWC
2
+
3
+ - v.1.0.0
4
+ + Setup project
5
+ + Added Component `flt-button`
6
+
7
+ -----------------------------------------
8
+
@@ -0,0 +1,13 @@
1
+ // BUTTON ->
2
+ $FLT_BUTTON_PRIMARY_BG_COLOR: var(--flt-button-primary-bg-color, #f2d400);
3
+ $FLT_BUTTON_PRIMARY_COLOR: var(--flt-button-primary-color, #111827);
4
+ $FLT_BUTTON_PRIMARY_DISABLED_COLOR: var(--flt-button-primary-disabled-color, #6b7280);
5
+ $FLT_BUTTON_PRIMARY_DISABLED_BG_COLOR: var(--flt-button-primary-disabled-bg-color, #f3f4f6);
6
+
7
+ $FLT_BUTTON_BASE_BG_COLOR: var(--flt-button-base-bg-color, #ffffff);
8
+ $FLT_BUTTON_BASE_COLOR: var(--flt-button-base-color, #111827);
9
+ $FLT_BUTTON_BASE_BORDER_COLOR: var(--flt-button-base-border-color, #111827);
10
+ $FLT_BUTTON_BASE_DISABLED_COLOR: var(--flt-button-base-disabled-color, #6b7280);
11
+ $FLT_BUTTON_BASE_DISABLED_BG_COLOR: var(--flt-button-base-disabled-bg-color, #f3f4f6);
12
+ $FLT_BUTTON_BASE_DISABLED_BORDER_COLOR: var(--flt-button-base-disabled-border-color, #6b7280);
13
+ // <- BUTTON
@@ -0,0 +1,13 @@
1
+ // BUTTON ->
2
+ $FLT_BUTTON_PRIMARY_BG_COLOR: var(--flt-button-primary-bg-color, #3782c8);
3
+ $FLT_BUTTON_PRIMARY_COLOR: var(--flt-button-primary-color, #f9fafb);
4
+ $FLT_BUTTON_PRIMARY_DISABLED_COLOR: var(--flt-button-primary-disabled-color, #6b7280);
5
+ $FLT_BUTTON_PRIMARY_DISABLED_BG_COLOR: var(--flt-button-primary-disabled-bg-color, #f3f4f6);
6
+
7
+ $FLT_BUTTON_BASE_BG_COLOR: var(--flt-button-base-bg-color, #ffffff);
8
+ $FLT_BUTTON_BASE_COLOR: var(--flt-button-base-color, #111827);
9
+ $FLT_BUTTON_BASE_BORDER_COLOR: var(--flt-button-base-border-color, #111827);
10
+ $FLT_BUTTON_BASE_DISABLED_COLOR: var(--flt-button-base-disabled-color, #6b7280);
11
+ $FLT_BUTTON_BASE_DISABLED_BG_COLOR: var(--flt-button-base-disabled-bg-color, #f3f4f6);
12
+ $FLT_BUTTON_BASE_DISABLED_BORDER_COLOR: var(--flt-button-base-disabled-border-color, #6b7280);
13
+ // <- BUTTON
@@ -0,0 +1,33 @@
1
+ import { createElement } from 'lwc'
2
+ import Button from 'flt/button'
3
+
4
+ describe('ui-button', () => {
5
+ afterEach(() => {
6
+ // The jsdom instance is shared across test cases in a single file so reset the DOM
7
+ while (document.body.firstChild) {
8
+ document.body.removeChild(document.body.firstChild)
9
+ }
10
+ })
11
+
12
+ it('displays greeting', () => {
13
+ // Create element
14
+ const element_1 = createElement('flt-button', {
15
+ is: Button
16
+ })
17
+ element_1.type = 'primary'
18
+ element_1.label = 'Add'
19
+ document.body.appendChild(element_1)
20
+ expect(element_1.firstChild.classList.contains('flt-button_primary')).toBeTruthy()
21
+
22
+ const element_2 = createElement('flt-button', {
23
+ is: Button
24
+ })
25
+ element_2.type = 'base'
26
+ element_2.disabled = true
27
+ element_2.label = 'Add'
28
+ document.body.appendChild(element_2)
29
+
30
+ expect(element_2.firstChild.classList.contains('flt-button_base')).toBeTruthy()
31
+ expect(element_2.firstChild.classList.contains('flt-button_disabled')).toBeTruthy()
32
+ })
33
+ })
@@ -0,0 +1,7 @@
1
+ <template lwc:render-mode="light">
2
+ <button class={cssClass} disabled={disabled}>
3
+ <flt-icon class="flt-button__icon-left" if:true={iconLeft} icon={iconLeft}></flt-icon>
4
+ {label}
5
+ <flt-icon class="flt-button__icon-right" if:true={iconRight} icon={iconRight}></flt-icon>
6
+ </button>
7
+ </template>
@@ -0,0 +1,30 @@
1
+ import './button.scss'
2
+ import { LightningElement, api } from 'lwc'
3
+
4
+ const PRIMARY = 'primary'
5
+ const BASE = 'base'
6
+ export default class Button extends LightningElement {
7
+ static renderMode = 'light'
8
+
9
+ @api type = PRIMARY
10
+ @api label
11
+ @api disabled
12
+ @api iconLeft
13
+ @api iconRight
14
+
15
+ get cssClass() {
16
+ let result = 'flt-button'
17
+
18
+ if (this.disabled) {
19
+ result += ' flt-button_disabled'
20
+ }
21
+
22
+ if (this.type === PRIMARY) {
23
+ result += ' flt-button_primary'
24
+ } else if (this.type === BASE) {
25
+ result += ' flt-button_base'
26
+ }
27
+
28
+ return result
29
+ }
30
+ }
@@ -0,0 +1,96 @@
1
+ @import './../../../common/mixins_aquamarine';
2
+ /* mixins */
3
+
4
+ button {
5
+ display: inline-block;
6
+ background: none repeat scroll 0 0 transparent;
7
+ border: medium none;
8
+ border-spacing: 0;
9
+ font-size: 16px;
10
+ list-style: none outside none;
11
+ margin: 0;
12
+ padding: 0;
13
+ text-decoration: none;
14
+ text-indent: 0;
15
+
16
+ &::-moz-focus-inner {
17
+ border: 0;
18
+ padding: 0;
19
+ }
20
+
21
+ &[disabled] {
22
+ color: initial;
23
+ }
24
+ }
25
+
26
+ @mixin flt-icon-path($stroke) {
27
+ .flt-icon__path {
28
+ stroke: $stroke;
29
+ }
30
+ }
31
+
32
+ @mixin flt-button-hover() {
33
+ &:hover {
34
+ box-shadow: 0px 4px 6px -1px rgba(16, 24, 40, 0.1), 0px 2px 4px -2px rgba(16, 24, 40, 0.1);
35
+ }
36
+ }
37
+
38
+ .flt-button {
39
+ cursor: pointer;
40
+ height: 48px;
41
+ display: flex;
42
+ align-items: center;
43
+ font-size: 16px;
44
+ font-weight: 500;
45
+ line-height: 18px;
46
+ font-family: inherit;
47
+ border-radius: 32px;
48
+ box-sizing: border-box;
49
+ padding: 0.75rem 2rem;
50
+
51
+ &_primary[disabled] {
52
+ cursor: not-allowed;
53
+ color: $FLT_BUTTON_PRIMARY_DISABLED_COLOR;
54
+ background-color: $FLT_BUTTON_PRIMARY_DISABLED_BG_COLOR;
55
+
56
+ @include flt-icon-path($FLT_BUTTON_PRIMARY_DISABLED_COLOR);
57
+ }
58
+
59
+ &_primary:not([disabled]) {
60
+ color: $FLT_BUTTON_PRIMARY_COLOR;
61
+ background-color: $FLT_BUTTON_PRIMARY_BG_COLOR;
62
+ transition: all 0.3s;
63
+
64
+ @include flt-button-hover();
65
+ @include flt-icon-path($FLT_BUTTON_PRIMARY_COLOR);
66
+ }
67
+
68
+ &_base:not([disabled]) {
69
+ color: $FLT_BUTTON_BASE_COLOR;
70
+ background-color: $FLT_BUTTON_BASE_BG_COLOR;
71
+ border: 1px solid $FLT_BUTTON_BASE_BORDER_COLOR;
72
+ transition: all 0.3s;
73
+
74
+ @include flt-button-hover();
75
+ @include flt-icon-path($FLT_BUTTON_BASE_COLOR);
76
+ }
77
+
78
+ &_base[disabled] {
79
+ cursor: not-allowed;
80
+ color: $FLT_BUTTON_BASE_DISABLED_COLOR;
81
+ background-color: $FLT_BUTTON_BASE_DISABLED_BG_COLOR;
82
+ border: 1px solid $FLT_BUTTON_BASE_DISABLED_BORDER_COLOR;
83
+
84
+ @include flt-icon-path($FLT_BUTTON_BASE_DISABLED_COLOR);
85
+ }
86
+
87
+ &__icon-left {
88
+ display: flex;
89
+ margin-right: 1rem;
90
+ }
91
+
92
+ &__icon-right {
93
+ display: flex;
94
+ margin-left: 1rem;
95
+ }
96
+ }
@@ -0,0 +1,30 @@
1
+ import { createElement } from 'lwc'
2
+ import Icon from 'flt/icon'
3
+
4
+ describe('flt-icon', () => {
5
+ afterEach(() => {
6
+ // The jsdom instance is shared across test cases in a single file so reset the DOM
7
+ while (document.body.firstChild) {
8
+ document.body.removeChild(document.body.firstChild)
9
+ }
10
+ })
11
+
12
+ it('displays greeting', () => {
13
+ // Create element
14
+ const element_1 = createElement('flt-icon', {
15
+ is: Icon
16
+ })
17
+ element_1.icon = 'arrow-right'
18
+ document.body.appendChild(element_1)
19
+
20
+ expect(element_1.firstChild.classList.contains('flt-icon__arrow-right')).toBeTruthy()
21
+
22
+ const element_2 = createElement('flt-icon', {
23
+ is: Icon
24
+ })
25
+ element_2.icon = 'arrow-left'
26
+ document.body.appendChild(element_2)
27
+
28
+ expect(element_2.firstChild.classList.contains('flt-icon__arrow-left')).toBeTruthy()
29
+ })
30
+ })
@@ -0,0 +1,15 @@
1
+ <template lwc:render-mode="light">
2
+ <svg
3
+ class="flt-icon flt-icon__arrow-left"
4
+ width="24"
5
+ height="24"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg">
9
+ <path
10
+ class="flt-icon__path"
11
+ d="M3 12H21M10 19L3 12L10 19ZM3 12L10 5L3 12Z"
12
+ stroke-linecap="round"
13
+ stroke-linejoin="round"></path>
14
+ </svg>
15
+ </template>
@@ -0,0 +1,15 @@
1
+ <template lwc:render-mode="light">
2
+ <svg
3
+ class="flt-icon flt-icon__arrow-right"
4
+ width="24"
5
+ height="24"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ xmlns="http://www.w3.org/2000/svg">
9
+ <path
10
+ class="flt-icon__path"
11
+ d="M21 12H3M14 5L21 12L14 5ZM21 12L14 19L21 12Z"
12
+ stroke-linecap="round"
13
+ stroke-linejoin="round"></path>
14
+ </svg>
15
+ </template>
@@ -0,0 +1,21 @@
1
+ import './icon.scss'
2
+ import { LightningElement, api } from 'lwc'
3
+ import TMPL_ARROW_RIGHT from './arrow-right.html'
4
+ import TMPL_ARROW_LEFT from './arrow-left.html'
5
+
6
+ const I_ARROW_RIGHT = 'arrow-right'
7
+ const I_ARROW_LEFT = 'arrow-left'
8
+
9
+ export default class Icon extends LightningElement {
10
+ static renderMode = 'light'
11
+
12
+ @api icon
13
+
14
+ render() {
15
+ let result = TMPL_ARROW_RIGHT
16
+ if (this.icon === I_ARROW_LEFT) {
17
+ result = TMPL_ARROW_LEFT
18
+ }
19
+ return result
20
+ }
21
+ }
@@ -0,0 +1,9 @@
1
+ .flt-icon {
2
+ width: 24px;
3
+ height: 24px;
4
+ display: inline-flex;
5
+
6
+ &__path {
7
+ stroke: #000;
8
+ }
9
+ }
@@ -0,0 +1,20 @@
1
+ const loaderUtils = require('loader-utils')
2
+ const fs = require('fs')
3
+ const path = require('path')
4
+
5
+ module.exports = function (source) {
6
+ const options = loaderUtils.getOptions(this)
7
+ let content = ''
8
+ if (options && options.mixins) {
9
+ const pathMixin = path.resolve(options.mixins)
10
+ this.addDependency(pathMixin)
11
+ content = fs.readFileSync(pathMixin).toString()
12
+ source = source.replace('/* mixins */', content)
13
+ } else if (options && options.theme) {
14
+ source = source.replace(
15
+ `@import './../../../common/mixins_flt';`,
16
+ `@import './../../../common/mixins_${options.theme}';`
17
+ )
18
+ }
19
+ return source
20
+ }
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "fleetcor-lwc",
3
+ "version": "1.0.0",
4
+ "description": "LWC framework by Fleetcor",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://git.fleetcor.com/Aleksandr.Zanko/fleetcor-lwc.git"
8
+ },
9
+ "author": "Fleetcor team",
10
+ "license": "ISC",
11
+ "files": [
12
+ "frontend/components/flt",
13
+ "frontend/common",
14
+ "loader"
15
+ ],
16
+ "lwc": {
17
+ "modules": [
18
+ {
19
+ "dir": "frontend/components"
20
+ }
21
+ ],
22
+ "expose": [
23
+ "flt/button"
24
+ ]
25
+ },
26
+ "keywords": [
27
+ "lwc"
28
+ ],
29
+ "scripts": {
30
+ "watch": "webpack serve --open --port 8080",
31
+ "test:unit": "sfdx-lwc-jest",
32
+ "test:unit:watch": "sfdx-lwc-jest --watch",
33
+ "test:unit:debug": "sfdx-lwc-jest --debug",
34
+ "test:unit:coverage": "sfdx-lwc-jest --coverage",
35
+ "prettier": "prettier --config .prettierrc --write ./"
36
+ },
37
+ "devDependencies": {
38
+ "@babel/core": "^7.15.0",
39
+ "@babel/plugin-proposal-optional-chaining": "^7.14.5",
40
+ "@babel/plugin-transform-runtime": "^7.15.0",
41
+ "@babel/preset-env": "^7.15.0",
42
+ "@salesforce/sfdx-lwc-jest": "^1.2.1",
43
+ "babel-loader": "^8.1.0",
44
+ "prettier": "^2.3.2",
45
+ "css-loader": "^6.2.0",
46
+ "html-loader": "^2.1.2",
47
+ "html-webpack-plugin": "^5.3.2",
48
+ "lwc": "^2.3.0",
49
+ "lwc-webpack-plugin": "^2.0.1",
50
+ "mini-css-extract-plugin": "^2.2.0",
51
+ "identity-obj-proxy": "^3.0.0",
52
+ "node-sass": "^7.0.1",
53
+ "postcss-loader": "^6.1.1",
54
+ "pug-html-loader": "^1.1.5",
55
+ "pug-loader": "^2.4.0",
56
+ "resolve-url-loader": "^4.0.0",
57
+ "sass": "^1.37.5",
58
+ "sass-loader": "^12.1.0",
59
+ "style-loader": "^3.2.1",
60
+ "webpack": "^5.48.0",
61
+ "webpack-cli": "^4.7.2",
62
+ "webpack-dev-server": "^3.11.2",
63
+ "d": "^1.0.1",
64
+ "loader-utils": "^2.0.0"
65
+ }
66
+ }