@lukso/web-components 1.2.1 → 1.3.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/CHANGELOG.md +22 -0
- package/README.md +4 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +1600 -529
- package/dist/components/index.umd.cjs +163 -42
- package/dist/components/lukso-button/index.d.ts +1 -0
- package/dist/components/lukso-button/index.js +131 -127
- package/dist/components/lukso-button/index.umd.cjs +16 -16
- package/dist/components/lukso-card/index.d.ts +19 -0
- package/dist/components/lukso-card/index.js +1541 -0
- package/dist/components/lukso-card/index.umd.cjs +144 -0
- package/dist/components/lukso-navbar/index.js +5 -3
- package/dist/components/lukso-navbar/index.umd.cjs +5 -3
- package/dist/components/lukso-profile/index.d.ts +25 -0
- package/dist/components/lukso-profile/index.js +1423 -0
- package/dist/components/lukso-profile/index.umd.cjs +90 -0
- package/dist/components/lukso-sanitize/index.d.ts +12 -0
- package/dist/components/lukso-sanitize/index.js +1626 -0
- package/dist/components/lukso-sanitize/index.umd.cjs +61 -0
- package/dist/components/lukso-tag/index.d.ts +20 -0
- package/dist/components/lukso-tag/index.js +1209 -0
- package/dist/components/lukso-tag/index.umd.cjs +67 -0
- package/dist/components/lukso-test/index.js +46 -46
- package/dist/components/lukso-test/index.umd.cjs +22 -22
- package/dist/components/lukso-username/index.d.ts +34 -0
- package/dist/components/lukso-username/index.js +1255 -0
- package/dist/components/lukso-username/index.umd.cjs +75 -0
- package/dist/components/lukso-wizard/index.js +3 -3
- package/dist/components/lukso-wizard/index.umd.cjs +3 -3
- package/dist/index.js +1600 -529
- package/dist/index.umd.cjs +163 -42
- package/dist/sass/typography.scss +4 -4
- package/dist/shared/tailwind-element/index.js +146 -146
- package/dist/shared/tailwind-element/index.umd.cjs +1 -1
- package/dist/shared/tailwind-element.js +146 -146
- package/dist/shared/tailwind-element.umd.cjs +1 -1
- package/dist/shared/utils/sliceAddress.d.ts +9 -0
- package/dist/styles/main.css +4 -4
- package/package.json +30 -2
- package/src/components/index.ts +5 -0
- package/src/components/lukso-button/index.ts +4 -0
- package/src/components/lukso-button/lukso-button.stories.ts +64 -5
- package/src/components/lukso-card/index.ts +118 -0
- package/src/components/lukso-card/lukso-card.stories.ts +135 -0
- package/src/components/lukso-navbar/index.ts +4 -2
- package/src/components/lukso-navbar/lukso-navbar.stories.ts +13 -4
- package/src/components/lukso-profile/index.ts +100 -0
- package/src/components/lukso-profile/lukso-profile.stories.ts +87 -0
- package/src/components/lukso-sanitize/index.ts +28 -0
- package/src/components/lukso-sanitize/lukso-sanitize.stories.ts +26 -0
- package/src/components/lukso-tag/index.ts +68 -0
- package/src/components/lukso-tag/lukso-tag.stories.ts +107 -0
- package/src/components/lukso-username/index.ts +104 -0
- package/src/components/lukso-username/lukso-username.stories.ts +94 -0
- package/src/components/lukso-wizard/index.ts +2 -2
- package/src/components/lukso-wizard/lukso-wizard.stories.ts +6 -2
- package/src/shared/styles/typography.scss +4 -4
- package/src/shared/utils/__tests__/sliceAddress.spec.ts +15 -0
- package/src/shared/utils/sliceAddress.ts +30 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { html } from 'lit'
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
3
|
+
import { sliceAddress } from '@/shared/utils/sliceAddress'
|
|
4
|
+
|
|
5
|
+
import { TailwindElement } from '@/shared/tailwind-element'
|
|
6
|
+
import { customClassMap } from '@/shared/directives/custom-class-map'
|
|
7
|
+
import { styleMap } from 'lit-html/directives/style-map.js'
|
|
8
|
+
|
|
9
|
+
export type UsernameSize = 'small' | 'large'
|
|
10
|
+
|
|
11
|
+
@customElement('lukso-username')
|
|
12
|
+
export class LuksoUsername extends TailwindElement {
|
|
13
|
+
@property({ type: String })
|
|
14
|
+
name = ''
|
|
15
|
+
|
|
16
|
+
@property({ type: String })
|
|
17
|
+
address = ''
|
|
18
|
+
|
|
19
|
+
@property({ type: Number, attribute: 'max-width' })
|
|
20
|
+
maxWidth = 200
|
|
21
|
+
|
|
22
|
+
@property({ type: 'string' })
|
|
23
|
+
size: UsernameSize = 'large'
|
|
24
|
+
|
|
25
|
+
@property({ type: Number, attribute: 'slice-by' })
|
|
26
|
+
sliceBy = 8
|
|
27
|
+
|
|
28
|
+
@property({ type: String, attribute: 'address-color' })
|
|
29
|
+
addressColor = 'neutral-20'
|
|
30
|
+
|
|
31
|
+
/** Width of the first 4 bytes of the address */
|
|
32
|
+
private bytesWidth = 52
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Template for 4byte address
|
|
36
|
+
* e.g: #1234
|
|
37
|
+
*/
|
|
38
|
+
private addressBytesTemplate() {
|
|
39
|
+
return html`<div class="inline-block text-neutral-60">
|
|
40
|
+
#${this.address.slice(2, 6)}
|
|
41
|
+
</div>`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Template for name
|
|
46
|
+
* e.g: @John
|
|
47
|
+
*/
|
|
48
|
+
private nameTemplate() {
|
|
49
|
+
return html`<div
|
|
50
|
+
class="inline-block whitespace-nowrap overflow-hidden text-ellipsis text-transparent
|
|
51
|
+
bg-clip-text bg-gradient-to-r from-gradient-1-start to-gradient-1-end"
|
|
52
|
+
style=${styleMap({
|
|
53
|
+
maxWidth: `${this.maxWidth - this.bytesWidth}px`,
|
|
54
|
+
})}
|
|
55
|
+
>
|
|
56
|
+
@${this.name}
|
|
57
|
+
</div>`
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Template for address
|
|
62
|
+
* e.g: 0x123...789
|
|
63
|
+
*/
|
|
64
|
+
private addressTemplate() {
|
|
65
|
+
return html`<div
|
|
66
|
+
class="inline-block ${customClassMap({
|
|
67
|
+
['text-' + this.addressColor]: this.addressColor !== 'neutral-20',
|
|
68
|
+
})}"
|
|
69
|
+
>
|
|
70
|
+
${sliceAddress(this.address, this.sliceBy, this.sliceBy)}
|
|
71
|
+
</div>`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render() {
|
|
75
|
+
const template = (() => {
|
|
76
|
+
if (this.name && this.address) {
|
|
77
|
+
return html`${this.nameTemplate()}${this.addressBytesTemplate()}`
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (this.name) {
|
|
81
|
+
return this.nameTemplate()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (this.address) {
|
|
85
|
+
return this.addressTemplate()
|
|
86
|
+
}
|
|
87
|
+
})()
|
|
88
|
+
|
|
89
|
+
return html`<div
|
|
90
|
+
class="inline-flex ${customClassMap({
|
|
91
|
+
'monospaced-12-bold': this.size === 'small',
|
|
92
|
+
'monospaced-16-bold': this.size === 'large',
|
|
93
|
+
})}"
|
|
94
|
+
>
|
|
95
|
+
${template}
|
|
96
|
+
</div>`
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare global {
|
|
101
|
+
interface HTMLElementTagNameMap {
|
|
102
|
+
'lukso-username': LuksoUsername
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { html } from 'lit-html'
|
|
2
|
+
import './index'
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Design System/Components/Username',
|
|
6
|
+
component: 'lukso-username',
|
|
7
|
+
argTypes: {
|
|
8
|
+
name: {
|
|
9
|
+
control: { type: 'text' },
|
|
10
|
+
},
|
|
11
|
+
address: {
|
|
12
|
+
control: { type: 'text' },
|
|
13
|
+
},
|
|
14
|
+
maxWidth: {
|
|
15
|
+
control: { type: 'number' },
|
|
16
|
+
if: { arg: 'name', neq: '' },
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
control: { type: 'select' },
|
|
20
|
+
options: ['large', 'small'],
|
|
21
|
+
},
|
|
22
|
+
sliceBy: {
|
|
23
|
+
control: { type: 'number' },
|
|
24
|
+
if: { arg: 'name', eq: '' },
|
|
25
|
+
},
|
|
26
|
+
addressColor: {
|
|
27
|
+
control: { type: 'text' },
|
|
28
|
+
if: { arg: 'name', eq: '' },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
args: {
|
|
32
|
+
name: 'John',
|
|
33
|
+
address: '0x9671Db683406EE0817B1f5cB6A3b3BD111477457',
|
|
34
|
+
maxWidth: 200,
|
|
35
|
+
size: 'large',
|
|
36
|
+
sliceBy: 8,
|
|
37
|
+
addressColor: '',
|
|
38
|
+
},
|
|
39
|
+
parameters: {
|
|
40
|
+
controls: {
|
|
41
|
+
exclude: ['bytesWidth', 'max-width', 'slice-by', 'address-color'],
|
|
42
|
+
},
|
|
43
|
+
design: {
|
|
44
|
+
type: 'figma',
|
|
45
|
+
url: 'https://www.figma.com/file/NFCh20xAq3Jg2g8A0DNC9I/UI-Library?node-id=1096%3A14641&t=W8onPGbREKjGG9sS-4',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const Template = ({ name, address, maxWidth, size, sliceBy, addressColor }) =>
|
|
51
|
+
html`<lukso-username
|
|
52
|
+
name=${name}
|
|
53
|
+
address=${address}
|
|
54
|
+
max-width=${maxWidth}
|
|
55
|
+
size=${size}
|
|
56
|
+
slice-by=${sliceBy}
|
|
57
|
+
address-color=${addressColor}
|
|
58
|
+
></lukso-username>`
|
|
59
|
+
|
|
60
|
+
export const DefaultUsername = Template.bind({})
|
|
61
|
+
|
|
62
|
+
export const LongName = Template.bind({})
|
|
63
|
+
LongName.args = {
|
|
64
|
+
name: 'ThisIsAReallyLongName',
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const OnlyName = Template.bind({})
|
|
68
|
+
OnlyName.args = {
|
|
69
|
+
address: '',
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const OnlyAddress = Template.bind({})
|
|
73
|
+
OnlyAddress.args = {
|
|
74
|
+
name: '',
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const SliceAddressBy4 = Template.bind({})
|
|
78
|
+
SliceAddressBy4.args = {
|
|
79
|
+
name: '',
|
|
80
|
+
sliceBy: 4,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const SmallAddress = Template.bind({})
|
|
84
|
+
SmallAddress.args = {
|
|
85
|
+
name: '',
|
|
86
|
+
size: 'small',
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const CustomAddressColor = Template.bind({})
|
|
90
|
+
CustomAddressColor.args = {
|
|
91
|
+
name: '',
|
|
92
|
+
addressColor: 'neutral-60',
|
|
93
|
+
size: 'small',
|
|
94
|
+
}
|
|
@@ -26,14 +26,14 @@ export class LuksoWizard extends TailwindElement {
|
|
|
26
26
|
|
|
27
27
|
stepTemplate(step: WizardStep, index: number) {
|
|
28
28
|
return html`<li
|
|
29
|
-
class="inline-flex flex-col items-center justify-end w-
|
|
29
|
+
class="inline-flex flex-col items-center justify-end w-[121px] first:-ml-12 last:-mr-12 relative
|
|
30
30
|
[&>.lukso-wizard-circle]:after:last:hidden ${customClassMap({
|
|
31
31
|
[this.completedStepStyles]: index + 1 < this.activeStep,
|
|
32
32
|
[this.activeStepStyles]: index + 1 === this.activeStep,
|
|
33
33
|
})}"
|
|
34
34
|
>
|
|
35
35
|
<div
|
|
36
|
-
class="text-purple-51 heading-h5-apax whitespace-pre-line flex text-center break-words"
|
|
36
|
+
class="text-purple-51 heading-h5-apax whitespace-pre-line flex text-center break-words uppercase"
|
|
37
37
|
>
|
|
38
38
|
${step.label}
|
|
39
39
|
</div>
|
|
@@ -3,7 +3,7 @@ import { html } from 'lit-html'
|
|
|
3
3
|
import '../lukso-wizard'
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
title: 'Design System/
|
|
6
|
+
title: 'Design System/Components/Wizard',
|
|
7
7
|
component: 'lukso-wizard',
|
|
8
8
|
argTypes: {
|
|
9
9
|
steps: {
|
|
@@ -33,6 +33,10 @@ LYXe`,
|
|
|
33
33
|
controls: {
|
|
34
34
|
exclude: ['activeStepStyles', 'completedStepStyles', 'active-step'],
|
|
35
35
|
},
|
|
36
|
+
design: {
|
|
37
|
+
type: 'figma',
|
|
38
|
+
url: 'https://www.figma.com/file/NFCh20xAq3Jg2g8A0DNC9I/UI-Library?node-id=1094%3A13512&t=AGmdbG8fXRENuU3o-4',
|
|
39
|
+
},
|
|
36
40
|
},
|
|
37
41
|
}
|
|
38
42
|
|
|
@@ -42,4 +46,4 @@ const Template = ({ steps, activeStep }) =>
|
|
|
42
46
|
active-step=${activeStep}
|
|
43
47
|
></lukso-wizard>`
|
|
44
48
|
|
|
45
|
-
export const
|
|
49
|
+
export const BasicWizard = Template.bind({})
|
|
@@ -104,19 +104,19 @@
|
|
|
104
104
|
|
|
105
105
|
// Monospaced
|
|
106
106
|
|
|
107
|
-
.
|
|
107
|
+
.monospaced-16-regular {
|
|
108
108
|
@apply text-16 not-italic font-400 leading-22 font-mono;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
.
|
|
111
|
+
.monospaced-16-bold {
|
|
112
112
|
@apply text-16 not-italic font-700 leading-22 font-mono;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
.
|
|
115
|
+
.monospaced-12-bold {
|
|
116
116
|
@apply text-12 not-italic font-700 leading-14 font-mono;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
.
|
|
119
|
+
.monospaced-10-bold {
|
|
120
120
|
@apply text-10 not-italic font-700 leading-14 font-mono;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { sliceAddress } from '../sliceAddress.js'
|
|
2
|
+
|
|
3
|
+
test('sliceAddress', () => {
|
|
4
|
+
expect(sliceAddress()).toEqual('')
|
|
5
|
+
expect(sliceAddress('0xA60DDd4eB501bd5bfeC3d50187C3889B658775B5')).toEqual(
|
|
6
|
+
'0xA60DDd...8775B5'
|
|
7
|
+
)
|
|
8
|
+
expect(sliceAddress('0xA60DDd4eB501bd5bfeC3d50187C3889B658775B5', 3)).toEqual(
|
|
9
|
+
'0xA60...5B5'
|
|
10
|
+
)
|
|
11
|
+
expect(
|
|
12
|
+
sliceAddress('0xA60DDd4eB501bd5bfeC3d50187C3889B658775B5', 3, 6)
|
|
13
|
+
).toEqual('0xA60...8775B5')
|
|
14
|
+
expect(sliceAddress('0xA60DDd4eB51', 10)).toEqual('0xA60DDd4eB51')
|
|
15
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shorten address by removing middle part, i.e: 0x123...789
|
|
3
|
+
*
|
|
4
|
+
* @param address - the address
|
|
5
|
+
* @param sliceBy - slice by amount from top and end, it doesn't include 0x
|
|
6
|
+
* @returns sliced address
|
|
7
|
+
*/
|
|
8
|
+
export const sliceAddress = (
|
|
9
|
+
address?: string,
|
|
10
|
+
startSliceBy = 6,
|
|
11
|
+
endSliceBy?: number
|
|
12
|
+
): string => {
|
|
13
|
+
if (!address) {
|
|
14
|
+
return ''
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let sliceAddress = ''
|
|
18
|
+
endSliceBy = endSliceBy || startSliceBy
|
|
19
|
+
|
|
20
|
+
if (address.length < startSliceBy + endSliceBy) {
|
|
21
|
+
return address
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
sliceAddress =
|
|
25
|
+
address.length > startSliceBy + 2
|
|
26
|
+
? `${address.slice(0, startSliceBy + 2)}...${address.slice(-endSliceBy)}`
|
|
27
|
+
: address
|
|
28
|
+
|
|
29
|
+
return sliceAddress
|
|
30
|
+
}
|