@lukso/web-components 1.2.2 → 1.3.1

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +4 -0
  3. package/dist/components/index.d.ts +5 -0
  4. package/dist/components/index.js +1597 -527
  5. package/dist/components/index.umd.cjs +159 -40
  6. package/dist/components/lukso-button/index.d.ts +1 -0
  7. package/dist/components/lukso-button/index.js +131 -127
  8. package/dist/components/lukso-button/index.umd.cjs +16 -16
  9. package/dist/components/lukso-card/index.d.ts +19 -0
  10. package/dist/components/lukso-card/index.js +1541 -0
  11. package/dist/components/lukso-card/index.umd.cjs +144 -0
  12. package/dist/components/lukso-navbar/index.js +2 -2
  13. package/dist/components/lukso-navbar/index.umd.cjs +2 -2
  14. package/dist/components/lukso-profile/index.d.ts +25 -0
  15. package/dist/components/lukso-profile/index.js +1423 -0
  16. package/dist/components/lukso-profile/index.umd.cjs +90 -0
  17. package/dist/components/lukso-sanitize/index.d.ts +12 -0
  18. package/dist/components/lukso-sanitize/index.js +1626 -0
  19. package/dist/components/lukso-sanitize/index.umd.cjs +61 -0
  20. package/dist/components/lukso-tag/index.d.ts +20 -0
  21. package/dist/components/lukso-tag/index.js +1209 -0
  22. package/dist/components/lukso-tag/index.umd.cjs +67 -0
  23. package/dist/components/lukso-test/index.js +154 -154
  24. package/dist/components/lukso-test/index.umd.cjs +22 -22
  25. package/dist/components/lukso-username/index.d.ts +34 -0
  26. package/dist/components/lukso-username/index.js +1256 -0
  27. package/dist/components/lukso-username/index.umd.cjs +75 -0
  28. package/dist/components/lukso-wizard/index.js +2 -2
  29. package/dist/components/lukso-wizard/index.umd.cjs +8 -8
  30. package/dist/index.js +1597 -527
  31. package/dist/index.umd.cjs +159 -40
  32. package/dist/sass/typography.scss +6 -6
  33. package/dist/shared/tailwind-element/index.js +1 -1
  34. package/dist/shared/tailwind-element/index.umd.cjs +1 -1
  35. package/dist/shared/tailwind-element.js +1 -1
  36. package/dist/shared/tailwind-element.umd.cjs +1 -1
  37. package/dist/shared/utils/sliceAddress.d.ts +9 -0
  38. package/dist/styles/main.css +6 -6
  39. package/package.json +30 -2
  40. package/src/components/index.ts +5 -0
  41. package/src/components/lukso-button/index.ts +4 -0
  42. package/src/components/lukso-button/lukso-button.stories.ts +64 -5
  43. package/src/components/lukso-card/index.ts +118 -0
  44. package/src/components/lukso-card/lukso-card.stories.ts +135 -0
  45. package/src/components/lukso-navbar/index.ts +1 -1
  46. package/src/components/lukso-navbar/lukso-navbar.stories.ts +13 -4
  47. package/src/components/lukso-profile/index.ts +100 -0
  48. package/src/components/lukso-profile/lukso-profile.stories.ts +87 -0
  49. package/src/components/lukso-sanitize/index.ts +28 -0
  50. package/src/components/lukso-sanitize/lukso-sanitize.stories.ts +26 -0
  51. package/src/components/lukso-tag/index.ts +68 -0
  52. package/src/components/lukso-tag/lukso-tag.stories.ts +107 -0
  53. package/src/components/lukso-username/index.ts +105 -0
  54. package/src/components/lukso-username/lukso-username.stories.ts +90 -0
  55. package/src/components/lukso-wizard/index.ts +1 -1
  56. package/src/components/lukso-wizard/lukso-wizard.stories.ts +6 -2
  57. package/src/shared/styles/typography.scss +6 -6
  58. package/src/shared/utils/__tests__/sliceAddress.spec.ts +15 -0
  59. package/src/shared/utils/sliceAddress.ts +30 -0
@@ -0,0 +1,68 @@
1
+ import { html } from 'lit'
2
+ import { customElement, property } from 'lit/decorators.js'
3
+ import { styleMap } from 'lit/directives/style-map.js'
4
+
5
+ import { TailwindElement } from '@/shared/tailwind-element'
6
+ import { customClassMap } from '@/shared/directives'
7
+
8
+ export type TagSizes = 'small' | 'large'
9
+
10
+ @customElement('lukso-tag')
11
+ export class LuksoTag extends TailwindElement {
12
+ @property({ type: String })
13
+ size: TagSizes = 'small'
14
+
15
+ @property({ type: Boolean, attribute: 'is-rounded' })
16
+ isRounded = false
17
+
18
+ @property({ type: String, attribute: 'background-color' })
19
+ backgroundColor = ''
20
+
21
+ @property({ type: String, attribute: 'text-color' })
22
+ textColor = ''
23
+
24
+ private defaultStyles = `rounded-lg inline-flex items-center justify-center border border-neutral-20 text-neutral-20`
25
+ private smallStyles = `paragraph-12-medium h-[28px]`
26
+ private largeStyles = `paragraph-14-medium h-[34px]`
27
+ private roundedStyles = `rounded-[56px]`
28
+
29
+ private padding = () => {
30
+ if (this.size === 'small' && this.isRounded) {
31
+ return 'px-3'
32
+ }
33
+
34
+ if (this.size === 'large') {
35
+ return 'px-4'
36
+ }
37
+
38
+ return 'px-2'
39
+ }
40
+
41
+ render() {
42
+ return html`
43
+ <div
44
+ data-testid="tag"
45
+ class=${customClassMap({
46
+ [this.defaultStyles]: true,
47
+ [this.padding()]: true,
48
+ [this.roundedStyles]: this.isRounded,
49
+ [this.smallStyles]: this.size === 'small',
50
+ [this.largeStyles]: this.size === 'large',
51
+ })}
52
+ style=${styleMap({
53
+ backgroundColor: this.backgroundColor,
54
+ borderColor: this.backgroundColor,
55
+ color: this.textColor,
56
+ })}
57
+ >
58
+ <slot></slot>
59
+ </div>
60
+ `
61
+ }
62
+ }
63
+
64
+ declare global {
65
+ interface HTMLElementTagNameMap {
66
+ 'lukso-tag': LuksoTag
67
+ }
68
+ }
@@ -0,0 +1,107 @@
1
+ import { html } from 'lit-html'
2
+ import './index'
3
+
4
+ export default {
5
+ title: 'Design System/Components/Tag',
6
+ component: 'lukso-tag',
7
+ argTypes: {
8
+ content: {
9
+ control: { type: 'text' },
10
+ },
11
+ isRounded: {
12
+ control: {
13
+ type: 'boolean',
14
+ },
15
+ },
16
+ size: {
17
+ control: {
18
+ type: 'select',
19
+ },
20
+ options: ['small', 'large'],
21
+ },
22
+ backgroundColor: {
23
+ control: {
24
+ type: 'color',
25
+ },
26
+ },
27
+ textColor: {
28
+ control: {
29
+ type: 'color',
30
+ },
31
+ },
32
+ },
33
+ args: {
34
+ size: 'small',
35
+ isRounded: false,
36
+ content: 'Small Tag',
37
+ backgroundColor: '',
38
+ textColor: '',
39
+ },
40
+ parameters: {
41
+ controls: {
42
+ exclude: [
43
+ 'defaultStyles',
44
+ 'smallStyles',
45
+ 'largeStyles',
46
+ 'roundedStyles',
47
+ 'is-rounded',
48
+ 'background-color',
49
+ 'text-color',
50
+ 'padding',
51
+ ],
52
+ },
53
+ },
54
+ }
55
+
56
+ const Template = ({ content, size, isRounded, backgroundColor, textColor }) =>
57
+ html`<lukso-tag
58
+ size=${size}
59
+ ?is-rounded=${isRounded}
60
+ background-color=${backgroundColor}
61
+ text-color=${textColor}
62
+ >${content}</lukso-tag
63
+ >`
64
+
65
+ export const DefaultTag = Template.bind({})
66
+ DefaultTag.parameters = {
67
+ design: {
68
+ type: 'figma',
69
+ url: 'https://www.figma.com/file/NFCh20xAq3Jg2g8A0DNC9I/UI-Library?node-id=375%3A3234&t=AGmdbG8fXRENuU3o-4',
70
+ },
71
+ }
72
+
73
+ export const LargeTag = Template.bind({})
74
+ LargeTag.args = {
75
+ size: 'large',
76
+ content: 'Large Tag',
77
+ }
78
+ LargeTag.parameters = {
79
+ design: {
80
+ type: 'figma',
81
+ url: 'https://www.figma.com/file/NFCh20xAq3Jg2g8A0DNC9I/UI-Library?node-id=375%3A3234&t=AGmdbG8fXRENuU3o-4',
82
+ },
83
+ }
84
+
85
+ export const RoundedTag = Template.bind({})
86
+ RoundedTag.args = {
87
+ isRounded: true,
88
+ }
89
+ RoundedTag.parameters = {
90
+ design: {
91
+ type: 'figma',
92
+ url: 'https://www.figma.com/file/NFCh20xAq3Jg2g8A0DNC9I/UI-Library?node-id=1083%3A13483&t=AGmdbG8fXRENuU3o-4',
93
+ },
94
+ }
95
+
96
+ export const CustomColorTag = Template.bind({})
97
+ CustomColorTag.args = {
98
+ content: 'Custom Color Tag',
99
+ backgroundColor: '#E96464',
100
+ textColor: '#FFFFFF',
101
+ }
102
+ CustomColorTag.parameters = {
103
+ design: {
104
+ type: 'figma',
105
+ url: 'https://www.figma.com/file/NFCh20xAq3Jg2g8A0DNC9I/UI-Library?node-id=375%3A3241&t=AGmdbG8fXRENuU3o-4',
106
+ },
107
+ }
@@ -0,0 +1,105 @@
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 !== '',
68
+ ['text-neutral-20']: this.addressColor === '',
69
+ })}"
70
+ >
71
+ ${sliceAddress(this.address, this.sliceBy, this.sliceBy)}
72
+ </div>`
73
+ }
74
+
75
+ render() {
76
+ const template = (() => {
77
+ if (this.name && this.address) {
78
+ return html`${this.nameTemplate()}${this.addressBytesTemplate()}`
79
+ }
80
+
81
+ if (this.name) {
82
+ return this.nameTemplate()
83
+ }
84
+
85
+ if (this.address) {
86
+ return this.addressTemplate()
87
+ }
88
+ })()
89
+
90
+ return html`<div
91
+ class="inline-flex ${customClassMap({
92
+ 'monospaced-12-bold': this.size === 'small',
93
+ 'monospaced-16-bold': this.size === 'large',
94
+ })}"
95
+ >
96
+ ${template}
97
+ </div>`
98
+ }
99
+ }
100
+
101
+ declare global {
102
+ interface HTMLElementTagNameMap {
103
+ 'lukso-username': LuksoUsername
104
+ }
105
+ }
@@ -0,0 +1,90 @@
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
+ size: 'small',
76
+ }
77
+
78
+ export const SliceAddressBy4 = Template.bind({})
79
+ SliceAddressBy4.args = {
80
+ name: '',
81
+ size: 'small',
82
+ sliceBy: 4,
83
+ }
84
+
85
+ export const CustomAddressColor = Template.bind({})
86
+ CustomAddressColor.args = {
87
+ name: '',
88
+ addressColor: 'neutral-60',
89
+ size: 'small',
90
+ }
@@ -26,7 +26,7 @@ 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-24 first:-ml-12 last:-mr-12 relative
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,
@@ -3,7 +3,7 @@ import { html } from 'lit-html'
3
3
  import '../lukso-wizard'
4
4
 
5
5
  export default {
6
- title: 'Design System/Atoms/Wizard',
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 Wizard = Template.bind({})
49
+ export const BasicWizard = Template.bind({})
@@ -33,11 +33,11 @@
33
33
  }
34
34
 
35
35
  .heading-h4-apax {
36
- @apply text-14 not-italic font-500 leading-20 font-apax;
36
+ @apply text-14 not-italic font-500 leading-20 font-apax uppercase tracking-[.08em];
37
37
  }
38
38
 
39
39
  .heading-h5-apax {
40
- @apply text-8 not-italic font-500 leading-10 font-apax;
40
+ @apply text-8 not-italic font-500 leading-10 font-apax uppercase tracking-[.08em];
41
41
  }
42
42
 
43
43
  // Paragraph
@@ -104,19 +104,19 @@
104
104
 
105
105
  // Monospaced
106
106
 
107
- .monospace-16-regular {
107
+ .monospaced-16-regular {
108
108
  @apply text-16 not-italic font-400 leading-22 font-mono;
109
109
  }
110
110
 
111
- .monospace-16-bold {
111
+ .monospaced-16-bold {
112
112
  @apply text-16 not-italic font-700 leading-22 font-mono;
113
113
  }
114
114
 
115
- .monospace-12-bold {
115
+ .monospaced-12-bold {
116
116
  @apply text-12 not-italic font-700 leading-14 font-mono;
117
117
  }
118
118
 
119
- .monospace-10-bold {
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
+ }