forked from forcedotcom/commerce-on-lightning-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommonButton.js
More file actions
68 lines (62 loc) · 1.52 KB
/
commonButton.js
File metadata and controls
68 lines (62 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* For full license text, see the LICENSE file in the repo
* root or https://opensource.org/licenses/apache-2-0/
*/
import { api, LightningElement } from 'lwc';
import {
generateButtonSizeClass,
generateButtonStretchClass,
generateButtonStyleClass,
generateElementAlignmentClass,
} from 'experience/styling';
export default class CommonButton extends LightningElement {
static renderMode = 'light';
@api
disabled = false;
/**
* The assistive text for the button.
* @type {?string}
*/
@api
assistiveText;
/**
* The button variant.
* @type {?('primary' | 'secondary' | 'tertiary')}
*/
@api
variant;
/**
* The button size.
* @type {?('small' | 'large')}
*/
@api
size;
/**
* The width of the button.
* @type {?('stretch' | 'standard')}
*/
@api
width;
/**
* The alignment of the content inside the button.
* @type {?('center' | 'left' | 'right')}
*/
@api
alignment;
@api
focus() {
this.querySelector('button')?.focus();
}
get buttonClasses() {
return [
'slds-button',
generateButtonStyleClass(this.variant ?? null),
generateButtonSizeClass(this.size ?? null),
generateButtonStretchClass(this.width ?? null),
generateElementAlignmentClass(this.alignment ?? null),
].join(' ');
}
}