oasys-lib 1.1.5 → 1.2.1-alpha.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/.browserslistrc +17 -0
- package/karma.conf.js +44 -0
- package/ng-package.json +10 -0
- package/package.json +3 -10
- package/src/assets/bloomandwild/variables.css +6 -1
- package/src/assets/bloomon/variables.css +8 -3
- package/src/assets/global/scss-breakpoints.scss +1 -1
- package/src/assets/global/variables.css +1 -1
- package/src/lib/components/button/button.component.html +16 -0
- package/src/lib/components/button/button.component.scss +188 -0
- package/src/lib/components/button/button.component.spec.ts +25 -0
- package/src/lib/components/button/button.component.ts +95 -0
- package/src/lib/components/button/button.modifiers.scss +101 -0
- package/src/lib/components/button/button.ts +48 -0
- package/src/lib/components/icon/icon.component.html +5 -0
- package/src/lib/components/icon/icon.component.scss +5 -0
- package/src/lib/components/icon/icon.component.spec.ts +25 -0
- package/src/lib/components/icon/icon.component.ts +50 -0
- package/src/lib/components/icon/icon.ts +25 -0
- package/src/lib/components/layout/Layout.ts +64 -0
- package/src/lib/components/layout/_layout.scss +105 -0
- package/src/lib/components/layout/box/box.component.scss +124 -0
- package/src/lib/components/layout/box/box.component.ts +103 -0
- package/src/lib/components/layout/container/container.component.scss +66 -0
- package/src/lib/components/layout/container/container.component.ts +70 -0
- package/src/lib/components/layout/grid/grid.component.scss +162 -0
- package/src/lib/components/layout/grid/grid.component.ts +103 -0
- package/src/lib/components/layout/stack/stack.component.scss +60 -0
- package/src/lib/components/layout/stack/stack.component.ts +58 -0
- package/src/lib/components/text/text.component.html +1 -0
- package/src/lib/components/text/text.component.scss +33 -0
- package/src/lib/components/text/text.component.spec.ts +25 -0
- package/src/lib/components/text/text.component.ts +29 -0
- package/src/lib/components/text/text.ts +1 -0
- package/src/lib/oasys-lib.module.ts +42 -0
- package/src/lib/oasys-lib.service.spec.ts +16 -0
- package/src/lib/oasys-lib.service.ts +9 -0
- package/src/lib/services/token.service.ts +37 -0
- package/src/lib/services/window.service.ts +16 -0
- package/{public-api.d.ts → src/public-api.ts} +7 -1
- package/src/test.ts +27 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +7 -0
- package/tsconfig.spec.json +17 -0
- package/bundles/oasys-lib.umd.js +0 -630
- package/bundles/oasys-lib.umd.js.map +0 -1
- package/esm2015/lib/components/button/button.component.js +0 -97
- package/esm2015/lib/components/button/button.js +0 -2
- package/esm2015/lib/components/icon/icon.component.js +0 -58
- package/esm2015/lib/components/icon/icon.js +0 -2
- package/esm2015/lib/components/layout/Layout.js +0 -2
- package/esm2015/lib/components/layout/box/box.component.js +0 -100
- package/esm2015/lib/components/layout/container/container.component.js +0 -81
- package/esm2015/lib/components/layout/grid/grid.component.js +0 -104
- package/esm2015/lib/components/layout/stack/stack.component.js +0 -65
- package/esm2015/lib/components/text/text.js +0 -2
- package/esm2015/lib/oasys-lib.module.js +0 -66
- package/esm2015/lib/services/token.service.js +0 -41
- package/esm2015/lib/services/window.service.js +0 -19
- package/esm2015/oasys-lib.js +0 -5
- package/esm2015/public-api.js +0 -11
- package/fesm2015/oasys-lib.js +0 -602
- package/fesm2015/oasys-lib.js.map +0 -1
- package/lib/components/button/button.component.d.ts +0 -32
- package/lib/components/button/button.component.d.ts.map +0 -1
- package/lib/components/button/button.d.ts +0 -18
- package/lib/components/button/button.d.ts.map +0 -1
- package/lib/components/icon/icon.component.d.ts +0 -26
- package/lib/components/icon/icon.component.d.ts.map +0 -1
- package/lib/components/icon/icon.d.ts +0 -3
- package/lib/components/icon/icon.d.ts.map +0 -1
- package/lib/components/layout/Layout.d.ts +0 -27
- package/lib/components/layout/Layout.d.ts.map +0 -1
- package/lib/components/layout/box/box.component.d.ts +0 -28
- package/lib/components/layout/box/box.component.d.ts.map +0 -1
- package/lib/components/layout/container/container.component.d.ts +0 -21
- package/lib/components/layout/container/container.component.d.ts.map +0 -1
- package/lib/components/layout/grid/grid.component.d.ts +0 -31
- package/lib/components/layout/grid/grid.component.d.ts.map +0 -1
- package/lib/components/layout/stack/stack.component.d.ts +0 -21
- package/lib/components/layout/stack/stack.component.d.ts.map +0 -1
- package/lib/components/text/text.d.ts +0 -2
- package/lib/components/text/text.d.ts.map +0 -1
- package/lib/oasys-lib.module.d.ts +0 -15
- package/lib/oasys-lib.module.d.ts.map +0 -1
- package/lib/services/token.service.d.ts +0 -12
- package/lib/services/token.service.d.ts.map +0 -1
- package/lib/services/window.service.d.ts +0 -7
- package/lib/services/window.service.d.ts.map +0 -1
- package/oasys-lib.d.ts +0 -6
- package/oasys-lib.d.ts.map +0 -1
- package/public-api.d.ts.map +0 -1
package/.browserslistrc
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
|
2
|
+
# For additional information regarding the format and rule options, please see:
|
|
3
|
+
# https://github.com/browserslist/browserslist#queries
|
|
4
|
+
|
|
5
|
+
# For the full list of supported browsers by the Angular framework, please see:
|
|
6
|
+
# https://angular.io/guide/browser-support
|
|
7
|
+
|
|
8
|
+
# You can see what browsers were selected by your queries by running:
|
|
9
|
+
# npx browserslist
|
|
10
|
+
|
|
11
|
+
last 1 Chrome version
|
|
12
|
+
last 1 Firefox version
|
|
13
|
+
last 2 Edge major versions
|
|
14
|
+
last 2 Safari major versions
|
|
15
|
+
last 2 iOS major versions
|
|
16
|
+
Firefox ESR
|
|
17
|
+
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
|
package/karma.conf.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Karma configuration file, see link for more information
|
|
2
|
+
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
+
|
|
4
|
+
module.exports = function (config) {
|
|
5
|
+
config.set({
|
|
6
|
+
basePath: '',
|
|
7
|
+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
+
plugins: [
|
|
9
|
+
require('karma-jasmine'),
|
|
10
|
+
require('karma-chrome-launcher'),
|
|
11
|
+
require('karma-jasmine-html-reporter'),
|
|
12
|
+
require('karma-coverage'),
|
|
13
|
+
require('@angular-devkit/build-angular/plugins/karma')
|
|
14
|
+
],
|
|
15
|
+
client: {
|
|
16
|
+
jasmine: {
|
|
17
|
+
// you can add configuration options for Jasmine here
|
|
18
|
+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
|
|
19
|
+
// for example, you can disable the random execution with `random: false`
|
|
20
|
+
// or set a specific seed with `seed: 4321`
|
|
21
|
+
},
|
|
22
|
+
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
23
|
+
},
|
|
24
|
+
jasmineHtmlReporter: {
|
|
25
|
+
suppressAll: true // removes the duplicated traces
|
|
26
|
+
},
|
|
27
|
+
coverageReporter: {
|
|
28
|
+
dir: require('path').join(__dirname, '../../coverage/oasys-lib'),
|
|
29
|
+
subdir: '.',
|
|
30
|
+
reporters: [
|
|
31
|
+
{ type: 'html' },
|
|
32
|
+
{ type: 'text-summary' }
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
reporters: ['progress', 'kjhtml'],
|
|
36
|
+
port: 9876,
|
|
37
|
+
colors: true,
|
|
38
|
+
logLevel: config.LOG_INFO,
|
|
39
|
+
autoWatch: true,
|
|
40
|
+
browsers: ['Chrome'],
|
|
41
|
+
singleRun: false,
|
|
42
|
+
restartOnFileChange: true
|
|
43
|
+
});
|
|
44
|
+
};
|
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oasys-lib",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.2.1-alpha.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": "^12.2.0",
|
|
6
6
|
"@angular/core": "^12.2.0"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"tslib": "^2.3.0"
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
"module": "fesm2015/oasys-lib.js",
|
|
13
|
-
"es2015": "fesm2015/oasys-lib.js",
|
|
14
|
-
"esm2015": "esm2015/oasys-lib.js",
|
|
15
|
-
"fesm2015": "fesm2015/oasys-lib.js",
|
|
16
|
-
"typings": "oasys-lib.d.ts",
|
|
17
|
-
"sideEffects": false
|
|
18
|
-
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Do not edit directly
|
|
3
|
-
* Generated on
|
|
3
|
+
* Generated on Tue, 03 Jan 2023 14:05:25 GMT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
:root .brand-tokens-bloomandwild {
|
|
@@ -77,6 +77,11 @@
|
|
|
77
77
|
--component-button-opacity-overlay-focus-visible: 0.0;
|
|
78
78
|
--component-button-border-radius: 0.2rem;
|
|
79
79
|
--component-button-text-transform: normal;
|
|
80
|
+
--component-heading-alignment-default: center;
|
|
81
|
+
--component-heading-alignment-functional: start;
|
|
82
|
+
--component-heading-gap-default: default;
|
|
83
|
+
--component-heading-gap-secondary: near;
|
|
84
|
+
--component-heading-gap-functional: tight;
|
|
80
85
|
--semantic-font-styles-heading-hero-size: 5.2rem;
|
|
81
86
|
--semantic-font-styles-heading-hero-line-height: 6.4rem;
|
|
82
87
|
--semantic-font-styles-heading-hero-mobile-size: 3.6rem;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Do not edit directly
|
|
3
|
-
* Generated on
|
|
3
|
+
* Generated on Tue, 03 Jan 2023 14:05:25 GMT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
:root .brand-tokens-bloomon {
|
|
@@ -77,6 +77,11 @@
|
|
|
77
77
|
--component-button-opacity-overlay-focus-visible: 0.0;
|
|
78
78
|
--component-button-border-radius: 2.4rem;
|
|
79
79
|
--component-button-text-transform: uppercase;
|
|
80
|
+
--component-heading-alignment-default: start;
|
|
81
|
+
--component-heading-alignment-functional: start;
|
|
82
|
+
--component-heading-gap-default: default;
|
|
83
|
+
--component-heading-gap-secondary: near;
|
|
84
|
+
--component-heading-gap-functional: tight;
|
|
80
85
|
--semantic-font-styles-heading-hero-size: 5.2rem;
|
|
81
86
|
--semantic-font-styles-heading-hero-line-height: 6.4rem;
|
|
82
87
|
--semantic-font-styles-heading-hero-mobile-size: 3.6rem;
|
|
@@ -131,8 +136,8 @@
|
|
|
131
136
|
--semantic-color-text-primary: #464646;
|
|
132
137
|
--semantic-color-text-primary-on-dark: #ffffff;
|
|
133
138
|
--semantic-color-text-primary-disabled: #898989;
|
|
134
|
-
--semantic-color-text-supporting: #
|
|
135
|
-
--semantic-color-text-supporting-on-dark: #
|
|
139
|
+
--semantic-color-text-supporting: #464646;
|
|
140
|
+
--semantic-color-text-supporting-on-dark: #ffffff;
|
|
136
141
|
--semantic-color-transparent: transparent;
|
|
137
142
|
--semantic-color-tint-success: #fff799;
|
|
138
143
|
--semantic-color-tint-warning: #ff9f80;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<button (click)="onClick()"
|
|
2
|
+
[routerLink]="button.href || null"
|
|
3
|
+
[ngClass]="button.buttonDisplayClasses"
|
|
4
|
+
[attr.disabled]="button.buttonDisabled === true || null"
|
|
5
|
+
[attr.aria-label]="accessibleButtonContent"
|
|
6
|
+
[attr.title]="accessibleButtonContent"
|
|
7
|
+
role="button">
|
|
8
|
+
<div class="button-content">
|
|
9
|
+
<ui-icon *ngIf="button.buttonIcon && button.buttonIconPlacement !== 'none'" [iconName]="button.buttonIcon" [iconSize]="button.buttonSize" [iconClass]="'buttonIcon'" [iconContext]="button.buttonIconPlacement"></ui-icon>
|
|
10
|
+
<span class="ui-text" [ngClass]="{'visuallyhidden': button.buttonIconPlacement === 'iconOnly'}">
|
|
11
|
+
<ng-content></ng-content>
|
|
12
|
+
</span>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="button-overlay"></div>
|
|
15
|
+
<div class="button-overlay-focus"></div>
|
|
16
|
+
</button>
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
@import './button.modifiers.scss';
|
|
2
|
+
|
|
3
|
+
ui-button button {
|
|
4
|
+
/* ---------------------
|
|
5
|
+
Button Reset
|
|
6
|
+
--------------------- */
|
|
7
|
+
border: 0;
|
|
8
|
+
padding: 0;
|
|
9
|
+
position: relative;
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
text-align: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
align-items: center;
|
|
14
|
+
border-style: solid;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
user-select: none;
|
|
17
|
+
appearance: none;
|
|
18
|
+
|
|
19
|
+
// Vendor Specific
|
|
20
|
+
-webkit-appearance: none;
|
|
21
|
+
-webkit-font-smoothing: antialiased;
|
|
22
|
+
-webkit-tap-highlight-color: transparent;
|
|
23
|
+
-webkit-touch-callout: none;
|
|
24
|
+
-webkit-user-select: none;
|
|
25
|
+
-khtml-user-select: none;
|
|
26
|
+
-moz-user-select: none;
|
|
27
|
+
-ms-user-select: none;
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/* ---------------------
|
|
32
|
+
Global Styles
|
|
33
|
+
--------------------- */
|
|
34
|
+
border-radius: var(--component-button-border-radius);
|
|
35
|
+
font-family: var(--semantic-font-family-body);
|
|
36
|
+
|
|
37
|
+
$buttonLineHeight: var(--component-button-line-height);
|
|
38
|
+
|
|
39
|
+
.button-content {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
|
|
43
|
+
.ui-icon {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
max-height: $buttonLineHeight;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ui-text {
|
|
50
|
+
text-transform: var(--component-button-text-transform);
|
|
51
|
+
letter-spacing: var(--component-button-letter-spacing);
|
|
52
|
+
font-weight: var(--component-button-font-weight);
|
|
53
|
+
line-height: $buttonLineHeight;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
/* ---------------------
|
|
60
|
+
Hover / Focus Overlay
|
|
61
|
+
--------------------- */
|
|
62
|
+
.button-overlay,
|
|
63
|
+
.button-overlay-focus {
|
|
64
|
+
position: absolute;
|
|
65
|
+
top: 0;
|
|
66
|
+
right: 0;
|
|
67
|
+
bottom: 0;
|
|
68
|
+
left: 0;
|
|
69
|
+
touch-action: none;
|
|
70
|
+
pointer-events: none;
|
|
71
|
+
border-radius: var(--component-button-border-radius);
|
|
72
|
+
opacity: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
&:hover {
|
|
78
|
+
.button-overlay {
|
|
79
|
+
opacity: var(--component-button-opacity-overlay-hover);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&:focus {
|
|
84
|
+
.button-overlay {
|
|
85
|
+
opacity: var(--component-button-opacity-overlay-focus);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:focus-visible {
|
|
90
|
+
.button-overlay {
|
|
91
|
+
opacity: var(--component-button-opacity-overlay-focus-visible);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
/* ---------------------
|
|
98
|
+
Keyboard Focus Outline
|
|
99
|
+
--------------------- */
|
|
100
|
+
&:focus-visible {
|
|
101
|
+
outline: none;
|
|
102
|
+
|
|
103
|
+
.button-overlay-focus {
|
|
104
|
+
$outlineGap: var(--component-button-outline-gap);
|
|
105
|
+
top: calc(#{$outlineGap} * -1);
|
|
106
|
+
right: calc(#{$outlineGap} * -1);
|
|
107
|
+
bottom: calc(#{$outlineGap} * -1);
|
|
108
|
+
left: calc(#{$outlineGap} * -1);
|
|
109
|
+
box-shadow: 0 0 0 var(--component-button-outline-width) var(--component-button-color-focus-visible);
|
|
110
|
+
opacity: 1;
|
|
111
|
+
border-radius: calc(var(--component-button-border-radius) + var(--component-button-outline-width));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&:focus {
|
|
116
|
+
outline: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
/* ---------------------
|
|
121
|
+
Button Colour Styles
|
|
122
|
+
--------------------- */
|
|
123
|
+
@each $buttonType in $buttonTypes {
|
|
124
|
+
&.type-#{$buttonType} {
|
|
125
|
+
@include buttonColors(($buttonType));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
/* ---------------------
|
|
131
|
+
Icon Color Styling - Inherits from text color
|
|
132
|
+
--------------------- */
|
|
133
|
+
.buttonIcon {
|
|
134
|
+
fill: currentColor;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
/* ---------------------
|
|
140
|
+
Button Size Variants
|
|
141
|
+
--------------------- */
|
|
142
|
+
@each $buttonSize in $buttonSizes {
|
|
143
|
+
&.size-#{$buttonSize} {
|
|
144
|
+
@include buttonSize(($buttonSize));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
@each $buttonSize in $outlineButtonSizes {
|
|
148
|
+
&.button--outline.size-#{$buttonSize} {
|
|
149
|
+
@include buttonSize($buttonSize, 'true');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
/* ---------------------
|
|
156
|
+
Disabled State
|
|
157
|
+
--------------------- */
|
|
158
|
+
&[disabled] {
|
|
159
|
+
background-color: var(--component-button-color-disabled-background);
|
|
160
|
+
border-color: var(--component-button-color-disabled-border);
|
|
161
|
+
color: var(--component-button-color-disabled-text);
|
|
162
|
+
cursor: default;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
/* ---------------------
|
|
168
|
+
Trailing Icon Placement
|
|
169
|
+
(uses row reverse to support RTL languages)
|
|
170
|
+
--------------------- */
|
|
171
|
+
&.button--has-icon.button--icon--trailing {
|
|
172
|
+
.button-content {
|
|
173
|
+
flex-direction: row-reverse;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
/* ---------------------
|
|
179
|
+
Full Width Style
|
|
180
|
+
--------------------- */
|
|
181
|
+
&.button--full-width {
|
|
182
|
+
display: flex;
|
|
183
|
+
width: 100%;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { OasysButtonComponent } from './button.component';
|
|
4
|
+
|
|
5
|
+
describe('OasysButtonComponent', () => {
|
|
6
|
+
let component: OasysButtonComponent;
|
|
7
|
+
let fixture: ComponentFixture<OasysButtonComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ OasysButtonComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(OasysButtonComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Component, Input, OnInit, Output, ViewEncapsulation, EventEmitter, ChangeDetectionStrategy, ChangeDetectorRef, OnChanges, ContentChild, ElementRef, AfterViewInit } from '@angular/core';
|
|
2
|
+
import { IconNames, IconContext } from '../icon/icon';
|
|
3
|
+
import { TextTransform } from '../text/text';
|
|
4
|
+
import {
|
|
5
|
+
// ButtonTypeOptions,
|
|
6
|
+
UIButton,
|
|
7
|
+
UIButtonBoolean,
|
|
8
|
+
UIButtonSize,
|
|
9
|
+
UIButtonType
|
|
10
|
+
} from './button';
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector:'ui-button',
|
|
14
|
+
templateUrl: './button.component.html',
|
|
15
|
+
styleUrls: ['./button.component.scss'],
|
|
16
|
+
encapsulation: ViewEncapsulation.None,
|
|
17
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
18
|
+
})
|
|
19
|
+
export class OasysButtonComponent implements OnInit, OnChanges, AfterViewInit {
|
|
20
|
+
|
|
21
|
+
button: UIButton;
|
|
22
|
+
|
|
23
|
+
// // Button Content
|
|
24
|
+
@Input() buttonIcon?: IconNames;
|
|
25
|
+
@Input() buttonIconPlacement: IconContext = 'leading';
|
|
26
|
+
|
|
27
|
+
// @Input() buttonText: string;
|
|
28
|
+
@ContentChild('buttonText') buttonText: ElementRef;
|
|
29
|
+
|
|
30
|
+
// Button Stylings
|
|
31
|
+
@Input() buttonSize: UIButtonSize = 'large';
|
|
32
|
+
@Input() buttonFullWidth: UIButtonBoolean = false;
|
|
33
|
+
@Input() buttonType: UIButtonType = 'primary';
|
|
34
|
+
@Input() buttonDisabled: boolean = false;
|
|
35
|
+
|
|
36
|
+
// Button Actions
|
|
37
|
+
@Input() href: string = '';
|
|
38
|
+
@Output() clicked: EventEmitter<void> = new EventEmitter();
|
|
39
|
+
|
|
40
|
+
buttonDisplayClasses: string[];
|
|
41
|
+
iconContext: IconContext = 'none';
|
|
42
|
+
textTransform!: TextTransform;
|
|
43
|
+
accessibleButtonContent: string;
|
|
44
|
+
outlineButtonTypes = ['secondary', 'secondary-inverse']
|
|
45
|
+
|
|
46
|
+
constructor(private changes: ChangeDetectorRef) { }
|
|
47
|
+
|
|
48
|
+
onClick(): void {
|
|
49
|
+
this.clicked.emit();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
createButton(): UIButton {
|
|
53
|
+
|
|
54
|
+
return <UIButton>{
|
|
55
|
+
buttonIcon: this.buttonIcon,
|
|
56
|
+
buttonIconPlacement: this.buttonIconPlacement,
|
|
57
|
+
buttonType: this.buttonType,
|
|
58
|
+
buttonSize: this.buttonSize,
|
|
59
|
+
buttonDisabled: this.buttonDisabled,
|
|
60
|
+
href: this.href,
|
|
61
|
+
target: '',
|
|
62
|
+
buttonDisplayClasses: [
|
|
63
|
+
`type-${this.buttonType}`,
|
|
64
|
+
`size-${this.buttonSize}`,
|
|
65
|
+
`${this.buttonIcon ? 'button--has-icon': ''}`,
|
|
66
|
+
`${this.buttonFullWidth ? 'button--full-width': ''}`,
|
|
67
|
+
`${this.buttonIcon ? 'button--icon--'+this.buttonIconPlacement : ''}`,
|
|
68
|
+
`${this.outlineButtonTypes.indexOf(this.buttonType) !== -1 ? 'button--outline' : ''}`
|
|
69
|
+
].filter((d) => !!d)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ngAfterViewInit(): void {
|
|
74
|
+
if(this.buttonText?.nativeElement?.innerText) {
|
|
75
|
+
this.accessibleButtonContent = this.buttonText.nativeElement.innerText;
|
|
76
|
+
} else {
|
|
77
|
+
throw new Error(`
|
|
78
|
+
No inner text found. All buttons should have text passed via ng-content to enable accessibility for screen readers, this includes icon-only buttons.
|
|
79
|
+
|
|
80
|
+
Pass content using the template variable #buttonText eg:
|
|
81
|
+
ui-button()
|
|
82
|
+
span(#buttonText) Buy All The Things
|
|
83
|
+
`)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
ngOnChanges(): void {
|
|
88
|
+
this.button = this.createButton();
|
|
89
|
+
this.changes.markForCheck();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
ngOnInit(): void {
|
|
93
|
+
this.button = this.createButton();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/* ---------------------
|
|
2
|
+
All button type variants
|
|
3
|
+
--------------------- */
|
|
4
|
+
$buttonTypes:
|
|
5
|
+
primary,
|
|
6
|
+
secondary,
|
|
7
|
+
tertiary,
|
|
8
|
+
primary-inverse,
|
|
9
|
+
secondary-inverse,
|
|
10
|
+
tertiary-inverse,
|
|
11
|
+
expressive,
|
|
12
|
+
danger,
|
|
13
|
+
facebook,
|
|
14
|
+
paypal,
|
|
15
|
+
trustpilot;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/* ---------------------
|
|
20
|
+
All button sizes
|
|
21
|
+
--------------------- */
|
|
22
|
+
$buttonSizes: large, small;
|
|
23
|
+
$outlineButtonSizes: large, small;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/* ---------------------
|
|
28
|
+
Generate Button Colours
|
|
29
|
+
--------------------- */
|
|
30
|
+
@mixin buttonColors($buttonType) {
|
|
31
|
+
background-color: var(--component-button-color-#{$buttonType}-background);
|
|
32
|
+
border-color: var(--component-button-color-#{$buttonType}-border);
|
|
33
|
+
color: var(--component-button-color-#{$buttonType}-text);
|
|
34
|
+
|
|
35
|
+
.button-overlay {
|
|
36
|
+
background-color: var(--component-button-color-#{$buttonType}-text);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/* ---------------------
|
|
43
|
+
Generate Button Sizes
|
|
44
|
+
--------------------- */
|
|
45
|
+
@mixin buttonSize($buttonSize, $isOutline: false) {
|
|
46
|
+
|
|
47
|
+
// Variables to override below
|
|
48
|
+
$buttonPadding: 0 !default;
|
|
49
|
+
$buttonBorderWidth: 0 !default;
|
|
50
|
+
|
|
51
|
+
$iconOffsetLeading: 0 !default;
|
|
52
|
+
$iconOffsetTrailing: 0 !default;
|
|
53
|
+
$iconOffsetIconOnly: 0 !default;
|
|
54
|
+
|
|
55
|
+
// Variables dont change if theres an outline
|
|
56
|
+
$buttonFontSize: var(--component-button-size-#{$buttonSize}-font-size);
|
|
57
|
+
$buttonInlineSpacing: var(--component-button-size-#{$buttonSize}-stack-spacing);
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@if $isOutline== 'true' {
|
|
61
|
+
$buttonPadding: var(--component-button-size-#{$buttonSize}-with-outline-padding-y) var(--component-button-size-#{$buttonSize}-with-outline-padding-x);
|
|
62
|
+
$buttonBorderWidth: var(--component-button-size-#{$buttonSize}-with-outline-border-width);
|
|
63
|
+
|
|
64
|
+
$iconOffsetLeading: calc(var(--component-button-size-#{$buttonSize}-with-outline-icon-offset-leading) * -1);
|
|
65
|
+
$iconOffsetTrailing: calc(var(--component-button-size-#{$buttonSize}-with-outline-icon-offset-trailing) * -1);
|
|
66
|
+
$iconOffsetIconOnly: calc(var(--component-button-size-#{$buttonSize}-with-outline-icon-offset-icon-only) * -1);
|
|
67
|
+
|
|
68
|
+
} @else {
|
|
69
|
+
$buttonPadding: var(--component-button-size-#{$buttonSize}-padding-y) var(--component-button-size-#{$buttonSize}-padding-x);
|
|
70
|
+
$buttonBorderWidth: var(--component-button-size-#{$buttonSize}-border-width);
|
|
71
|
+
|
|
72
|
+
$iconOffsetLeading: calc(var(--component-button-size-#{$buttonSize}-icon-offset-leading) * -1);
|
|
73
|
+
$iconOffsetTrailing: calc(var(--component-button-size-#{$buttonSize}-icon-offset-trailing) * -1);
|
|
74
|
+
$iconOffsetIconOnly: calc(var(--component-button-size-#{$buttonSize}-icon-offset-icon-only) * -1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// TODO remove properly
|
|
78
|
+
padding: $buttonPadding;
|
|
79
|
+
border-width: $buttonBorderWidth;
|
|
80
|
+
font-size: $buttonFontSize;
|
|
81
|
+
|
|
82
|
+
.button-content {
|
|
83
|
+
gap: $buttonInlineSpacing;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ui-icon {
|
|
87
|
+
|
|
88
|
+
&.icon-context-leading {
|
|
89
|
+
margin-left: #{$iconOffsetLeading};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&.icon-context-trailing {
|
|
93
|
+
margin-right: #{$iconOffsetTrailing}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&.icon-context-iconOnly {
|
|
97
|
+
margin-left: #{$iconOffsetIconOnly};
|
|
98
|
+
margin-right: #{$iconOffsetIconOnly}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { EventEmitter } from '@angular/core';
|
|
2
|
+
import { IconNames, IconContext } from '../icon/icon';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export type UIButtonBoolean = true | 'true' | false | 'false';
|
|
6
|
+
|
|
7
|
+
export type UIButtonSize = 'small' | 'large';
|
|
8
|
+
|
|
9
|
+
export type UIButtonType =
|
|
10
|
+
| 'primary'
|
|
11
|
+
| 'secondary'
|
|
12
|
+
| 'tertiary'
|
|
13
|
+
| 'primary-inverse'
|
|
14
|
+
| 'secondary-inverse'
|
|
15
|
+
| 'tertiary-inverse'
|
|
16
|
+
| 'expressive'
|
|
17
|
+
| 'danger'
|
|
18
|
+
| 'facebook'
|
|
19
|
+
| 'paypal'
|
|
20
|
+
| 'trustpilot';
|
|
21
|
+
|
|
22
|
+
export interface UIButton {
|
|
23
|
+
|
|
24
|
+
// Inputs
|
|
25
|
+
|
|
26
|
+
// icon name
|
|
27
|
+
buttonIcon: IconNames;
|
|
28
|
+
// color/styling of button
|
|
29
|
+
buttonType: UIButtonType;
|
|
30
|
+
// positioning for icon
|
|
31
|
+
buttonIconPlacement: IconContext
|
|
32
|
+
// button size
|
|
33
|
+
buttonSize: UIButtonSize;
|
|
34
|
+
// Full width
|
|
35
|
+
buttonFullWidth: UIButtonBoolean;
|
|
36
|
+
// For links, expects relative or absolute url
|
|
37
|
+
href: string;
|
|
38
|
+
target: string;
|
|
39
|
+
buttonDisabled: UIButtonBoolean;
|
|
40
|
+
|
|
41
|
+
// Private properties
|
|
42
|
+
buttonDisplayClasses: string[];
|
|
43
|
+
|
|
44
|
+
// Outputs
|
|
45
|
+
|
|
46
|
+
// Click event, used when no href input
|
|
47
|
+
buttonDidClick: EventEmitter<any>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<div class="ui-icon" [ngClass]="iconDisplayClasses">
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" attr.width="{{iconWidth}}px" attr.height="{{iconHeight}}px" attr.class="{{iconClass}}">
|
|
3
|
+
<use attr.xlink:href="./{{iconBrandPath}}/assets/icons/icons.svg#icon-{{iconName}}"></use>
|
|
4
|
+
</svg>
|
|
5
|
+
</div>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { IconComponent } from './icon.component';
|
|
4
|
+
|
|
5
|
+
describe('IconComponent', () => {
|
|
6
|
+
let component: IconComponent;
|
|
7
|
+
let fixture: ComponentFixture<IconComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
declarations: [ IconComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
fixture = TestBed.createComponent(IconComponent);
|
|
18
|
+
component = fixture.componentInstance;
|
|
19
|
+
fixture.detectChanges();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should create', () => {
|
|
23
|
+
expect(component).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
});
|