@stellar-expert/ui-framework 1.16.7 → 1.17.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/CLAUDE.md +35 -0
- package/README.md +1125 -3
- package/account/account-address.js +127 -127
- package/account/available-balance.js +22 -22
- package/account/identicon.js +90 -90
- package/account/signer-key.js +65 -64
- package/api/explorer-api-hooks.js +209 -202
- package/api/explorer-api-paginated-list-hooks.js +441 -440
- package/api/explorer-batch-info-loader.js +111 -85
- package/api/explorer-tx-api.js +28 -28
- package/api/ledger-stream.js +15 -0
- package/asset/amount.js +56 -56
- package/asset/asset-icon.js +41 -41
- package/asset/asset-issuer.js +21 -21
- package/asset/asset-link.js +107 -107
- package/asset/asset-list-hooks.js +59 -59
- package/asset/asset-meta-hooks.js +88 -88
- package/asset/asset-selector.js +72 -71
- package/basic-styles/base.scss +50 -50
- package/basic-styles/grid.scss +1 -1
- package/basic-styles/table.scss +1 -1
- package/claimable-balance/claimable-balance-claimants.js +5 -0
- package/contract/contract-api.js +15 -0
- package/contract/invocation-info-view.js +10 -2
- package/contract/sc-val.js +24 -0
- package/controls/button-group.js +25 -19
- package/controls/button-group.scss +46 -46
- package/controls/button.js +93 -78
- package/controls/button.scss +173 -173
- package/controls/code-block.js +42 -34
- package/controls/code-block.scss +71 -71
- package/controls/dropdown.js +318 -287
- package/controls/dropdown.scss +159 -159
- package/controls/external-link.js +10 -4
- package/controls/info-tooltip.js +23 -16
- package/controls/slider.js +29 -19
- package/controls/tabs.js +94 -94
- package/controls/tabs.scss +70 -70
- package/controls/tooltip.js +244 -240
- package/controls/tooltip.scss +116 -116
- package/controls/update-highlighter.js +32 -27
- package/controls/update-highlighter.scss +7 -7
- package/date/date-selector.js +56 -54
- package/date/elapsed-time.js +28 -21
- package/dex/price-dynamic.js +53 -44
- package/dex/price-dynamic.scss +33 -33
- package/directory/directory-hooks.js +109 -97
- package/effect/effect-description.js +5 -3
- package/errors/error-boundary.js +110 -97
- package/horizon/horizon-account-helpers.js +104 -104
- package/horizon/horizon-ledger-helpers.js +35 -35
- package/horizon/horizon-trades-helper.js +88 -88
- package/horizon/horizon-transaction-helpers.js +36 -36
- package/index.d.ts +1241 -0
- package/interaction/accordion.js +43 -35
- package/interaction/autofocus.js +13 -9
- package/interaction/block-select.js +64 -53
- package/interaction/block-select.scss +21 -21
- package/interaction/copy-to-clipboard.js +25 -18
- package/interaction/inline-progress.js +20 -15
- package/interaction/qr-code.js +34 -34
- package/interaction/responsive.js +20 -20
- package/interaction/spoiler.js +52 -39
- package/interaction/spoiler.scss +6 -6
- package/interaction/theme-selector.js +13 -10
- package/ledger/ledger-entry-href-formatter.js +4 -3
- package/ledger/ledger-entry-link.js +93 -58
- package/ledger/ledger-info-parser.js +28 -0
- package/meta/page-meta-tags.js +243 -238
- package/module/dynamic-module.js +47 -47
- package/package.json +3 -2
- package/state/on-screen-hooks.js +22 -22
- package/state/page-visibility-helpers.js +29 -16
- package/state/page-visibility-hooks.js +13 -11
- package/state/screen-orientation-hooks.js +19 -15
- package/state/state-hooks.js +76 -76
- package/state/stellar-network-hooks.js +56 -44
- package/state/theme.js +29 -28
- package/stellar/key-type.js +92 -91
- package/stellar/ledger-generic-id.js +39 -39
- package/stellar/signature-hint-utils.js +65 -65
- package/toast/toast-notifications-block.js +59 -59
- package/toast/toast-notifications.scss +1 -1
- package/tx/op-description-view.js +84 -81
- package/tx/op-icon.js +98 -98
- package/tx/parser/op-balance-changes.js +66 -66
- package/tx/parser/op-descriptor.js +51 -48
- package/tx/parser/tx-details-parser.js +81 -81
- package/tx/parser/tx-matcher.js +371 -371
- package/tx/parser/type-filter-matcher.js +126 -126
- package/tx/tx-list-hooks.js +32 -18
- package/tx/tx-operations-list.js +117 -116
package/controls/button.js
CHANGED
|
@@ -1,79 +1,94 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import cn from 'classnames'
|
|
4
|
-
import './button.scss'
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import cn from 'classnames'
|
|
4
|
+
import './button.scss'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Versatile button component rendered as `<button>` or `<a>` tag
|
|
8
|
+
* @param {Object} props
|
|
9
|
+
* @param {string} [props.href] - Link URL; renders as `<a>` tag when set
|
|
10
|
+
* @param {function} [props.onClick] - Click handler
|
|
11
|
+
* @param {boolean} [props.block] - Render as a block-level element
|
|
12
|
+
* @param {boolean} [props.outline] - Render with outline style instead of filled
|
|
13
|
+
* @param {boolean} [props.clear] - Render with no outline, text only
|
|
14
|
+
* @param {boolean} [props.stackable] - Stack buttons on mobile devices
|
|
15
|
+
* @param {boolean} [props.small] - Render a smaller button
|
|
16
|
+
* @param {boolean} [props.disabled] - Disable the button
|
|
17
|
+
* @param {boolean} [props.loading] - Show loading animation
|
|
18
|
+
* @param {string} [props.className] - Additional CSS classes
|
|
19
|
+
* @param {*} props.children - Button content
|
|
20
|
+
*/
|
|
21
|
+
export const Button = React.memo(function Button({href, onClick, block, outline, clear, stackable, small, disabled, loading, className, children, ...op}) {
|
|
22
|
+
const c = cn('button', {
|
|
23
|
+
small,
|
|
24
|
+
disabled,
|
|
25
|
+
loading,
|
|
26
|
+
'button-block': block,
|
|
27
|
+
'button-outline': outline,
|
|
28
|
+
'button-clear': clear,
|
|
29
|
+
stackable
|
|
30
|
+
}, className)
|
|
31
|
+
const props = {className: c, onClick, ...op}
|
|
32
|
+
if (href) {
|
|
33
|
+
props.onClick = function (e) {
|
|
34
|
+
e.preventDefault()
|
|
35
|
+
return false
|
|
36
|
+
}
|
|
37
|
+
return <a href={href} {...props}>{children}</a>
|
|
38
|
+
}
|
|
39
|
+
if (disabled) {
|
|
40
|
+
props.disabled = true
|
|
41
|
+
}
|
|
42
|
+
return <button {...props}>{children}</button>
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
Button.propTypes = {
|
|
46
|
+
/**
|
|
47
|
+
* Button link - renders the button as A tag; if not set, BUTTON tag is rendered instead
|
|
48
|
+
*/
|
|
49
|
+
href: PropTypes.string,
|
|
50
|
+
/**
|
|
51
|
+
* Click handler
|
|
52
|
+
*/
|
|
53
|
+
onClick: PropTypes.func,
|
|
54
|
+
/**
|
|
55
|
+
* Whether to render the button as block element
|
|
56
|
+
*/
|
|
57
|
+
block: PropTypes.bool,
|
|
58
|
+
/**
|
|
59
|
+
* Render only a thin outline instead of the color-filled button
|
|
60
|
+
*/
|
|
61
|
+
outline: PropTypes.bool,
|
|
62
|
+
/**
|
|
63
|
+
* Do not render an outline - just the text
|
|
64
|
+
*/
|
|
65
|
+
clear: PropTypes.bool,
|
|
66
|
+
/**
|
|
67
|
+
* Whether buttons should look stackable on mobile devices
|
|
68
|
+
*/
|
|
69
|
+
stackable: PropTypes.bool,
|
|
70
|
+
/**
|
|
71
|
+
* Renders a small button
|
|
72
|
+
*/
|
|
73
|
+
small: PropTypes.bool,
|
|
74
|
+
/**
|
|
75
|
+
* Whether the button is currently disabled
|
|
76
|
+
*/
|
|
77
|
+
disabled: PropTypes.bool,
|
|
78
|
+
/**
|
|
79
|
+
* Show loading animation on the button
|
|
80
|
+
*/
|
|
81
|
+
loading: PropTypes.bool,
|
|
82
|
+
/**
|
|
83
|
+
* Externally provided CSS classes
|
|
84
|
+
*/
|
|
85
|
+
className: PropTypes.string,
|
|
86
|
+
/**
|
|
87
|
+
* Tooltip text
|
|
88
|
+
*/
|
|
89
|
+
title: PropTypes.string,
|
|
90
|
+
/**
|
|
91
|
+
* Text inside the button
|
|
92
|
+
*/
|
|
93
|
+
children: PropTypes.any.isRequired
|
|
79
94
|
}
|
package/controls/button.scss
CHANGED
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
$button-spacing: 0.5rem;
|
|
2
|
-
|
|
3
|
-
.button,
|
|
4
|
-
button {
|
|
5
|
-
border: none;
|
|
6
|
-
color: var(--color-bg);
|
|
7
|
-
background: none;
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
display: inline-block;
|
|
10
|
-
font-size: $font-size-base;
|
|
11
|
-
font-weight: 400;
|
|
12
|
-
font-family: $font-face-primary;
|
|
13
|
-
height: 2.4em;
|
|
14
|
-
min-width: 6em;
|
|
15
|
-
line-height: 2.4em;
|
|
16
|
-
padding: 0 1.4em;
|
|
17
|
-
text-align: center;
|
|
18
|
-
text-decoration: none;
|
|
19
|
-
white-space: nowrap;
|
|
20
|
-
margin-right: $button-spacing;
|
|
21
|
-
margin-bottom: 0.5em;
|
|
22
|
-
position: relative;
|
|
23
|
-
z-index: 0;
|
|
24
|
-
user-select: none;
|
|
25
|
-
|
|
26
|
-
&.button-block {
|
|
27
|
-
display: block;
|
|
28
|
-
width: 100%;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&:last-child {
|
|
32
|
-
margin-right: 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&.small {
|
|
36
|
-
font-size: 1.25rem;
|
|
37
|
-
padding: 0 1em;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&:before {
|
|
41
|
-
content: '';
|
|
42
|
-
display: block;
|
|
43
|
-
background: var(--color-highlight);
|
|
44
|
-
border: none;
|
|
45
|
-
position: absolute;
|
|
46
|
-
z-index: -1;
|
|
47
|
-
top: 0;
|
|
48
|
-
left: 6px;
|
|
49
|
-
width: calc(100% - 12px);
|
|
50
|
-
height: 100%;
|
|
51
|
-
transform: skew(-20deg);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
&:focus {
|
|
55
|
-
outline: 0;
|
|
56
|
-
background: none !important;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
&:hover {
|
|
60
|
-
color: var(--color-bg);
|
|
61
|
-
|
|
62
|
-
&:before {
|
|
63
|
-
background: var(--color-primary);
|
|
64
|
-
border-color: var(--color-primary);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
&:active {
|
|
69
|
-
&:before {
|
|
70
|
-
top: 1px;
|
|
71
|
-
left: 7px;
|
|
72
|
-
background: var(--color-primary);
|
|
73
|
-
border-color: var(--color-primary);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&[disabled],
|
|
78
|
-
&.disabled {
|
|
79
|
-
cursor: default !important;
|
|
80
|
-
opacity: 0.7;
|
|
81
|
-
|
|
82
|
-
&:hover,
|
|
83
|
-
&:active {
|
|
84
|
-
&:before {
|
|
85
|
-
background: var(--color-primary);
|
|
86
|
-
border-color: var(--color-primary);
|
|
87
|
-
top: 0;
|
|
88
|
-
left: 6px;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
&.button-outline {
|
|
94
|
-
color: var(--color-highlight);
|
|
95
|
-
|
|
96
|
-
&:before {
|
|
97
|
-
border: 1px solid var(--color-highlight);
|
|
98
|
-
background: var(--color-bg);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
&:hover {
|
|
102
|
-
&:before {
|
|
103
|
-
background: var(--color-bg);
|
|
104
|
-
border-color: var(--color-primary);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
&[disabled],
|
|
109
|
-
&.disabled {
|
|
110
|
-
&:focus,
|
|
111
|
-
&:hover {
|
|
112
|
-
color: var(--color-highlight);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
&:before {
|
|
116
|
-
background: var(--color-bg);
|
|
117
|
-
border-color: var(--color-highlight);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
&.button-clear {
|
|
123
|
-
color: var(--color-highlight);
|
|
124
|
-
|
|
125
|
-
&:focus,
|
|
126
|
-
&:hover {
|
|
127
|
-
color: var(--color-primary);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
&[disabled],
|
|
131
|
-
&.disabled {
|
|
132
|
-
&:focus,
|
|
133
|
-
&:hover {
|
|
134
|
-
color: var(--color-highlight);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
&.loading:after {
|
|
140
|
-
content: "";
|
|
141
|
-
display: block;
|
|
142
|
-
position: absolute;
|
|
143
|
-
top: 0;
|
|
144
|
-
left: 0;
|
|
145
|
-
width: 20%;
|
|
146
|
-
height: 100%;
|
|
147
|
-
opacity: 0.4;
|
|
148
|
-
background: linear-gradient(to right, transparent, var(--color-text) 50%, transparent);
|
|
149
|
-
transform: skew(-20deg) translateX(0);
|
|
150
|
-
animation: loading-button 3s infinite ease-in-out;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
@keyframes loading-button {
|
|
155
|
-
0% {
|
|
156
|
-
left: 0;
|
|
157
|
-
}
|
|
158
|
-
50% {
|
|
159
|
-
left: 80%;
|
|
160
|
-
}
|
|
161
|
-
100% {
|
|
162
|
-
left: 0;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
@media (max-width: $responsive-mobile-browser-width) {
|
|
167
|
-
button,
|
|
168
|
-
.button {
|
|
169
|
-
&.stackable {
|
|
170
|
-
display: block;
|
|
171
|
-
width: 100%;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
1
|
+
$button-spacing: 0.5rem;
|
|
2
|
+
|
|
3
|
+
.button,
|
|
4
|
+
button {
|
|
5
|
+
border: none;
|
|
6
|
+
color: var(--color-bg);
|
|
7
|
+
background: none;
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
display: inline-block;
|
|
10
|
+
font-size: $font-size-base;
|
|
11
|
+
font-weight: 400;
|
|
12
|
+
font-family: $font-face-primary;
|
|
13
|
+
height: 2.4em;
|
|
14
|
+
min-width: 6em;
|
|
15
|
+
line-height: 2.4em;
|
|
16
|
+
padding: 0 1.4em;
|
|
17
|
+
text-align: center;
|
|
18
|
+
text-decoration: none;
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
margin-right: $button-spacing;
|
|
21
|
+
margin-bottom: 0.5em;
|
|
22
|
+
position: relative;
|
|
23
|
+
z-index: 0;
|
|
24
|
+
user-select: none;
|
|
25
|
+
|
|
26
|
+
&.button-block {
|
|
27
|
+
display: block;
|
|
28
|
+
width: 100%;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:last-child {
|
|
32
|
+
margin-right: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.small {
|
|
36
|
+
font-size: 1.25rem;
|
|
37
|
+
padding: 0 1em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&:before {
|
|
41
|
+
content: '';
|
|
42
|
+
display: block;
|
|
43
|
+
background: var(--color-highlight);
|
|
44
|
+
border: none;
|
|
45
|
+
position: absolute;
|
|
46
|
+
z-index: -1;
|
|
47
|
+
top: 0;
|
|
48
|
+
left: 6px;
|
|
49
|
+
width: calc(100% - 12px);
|
|
50
|
+
height: 100%;
|
|
51
|
+
transform: skew(-20deg);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&:focus {
|
|
55
|
+
outline: 0;
|
|
56
|
+
background: none !important;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&:hover {
|
|
60
|
+
color: var(--color-bg);
|
|
61
|
+
|
|
62
|
+
&:before {
|
|
63
|
+
background: var(--color-primary);
|
|
64
|
+
border-color: var(--color-primary);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&:active {
|
|
69
|
+
&:before {
|
|
70
|
+
top: 1px;
|
|
71
|
+
left: 7px;
|
|
72
|
+
background: var(--color-primary);
|
|
73
|
+
border-color: var(--color-primary);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&[disabled],
|
|
78
|
+
&.disabled {
|
|
79
|
+
cursor: default !important;
|
|
80
|
+
opacity: 0.7;
|
|
81
|
+
|
|
82
|
+
&:hover,
|
|
83
|
+
&:active {
|
|
84
|
+
&:before {
|
|
85
|
+
background: var(--color-primary);
|
|
86
|
+
border-color: var(--color-primary);
|
|
87
|
+
top: 0;
|
|
88
|
+
left: 6px;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&.button-outline {
|
|
94
|
+
color: var(--color-highlight);
|
|
95
|
+
|
|
96
|
+
&:before {
|
|
97
|
+
border: 1px solid var(--color-highlight);
|
|
98
|
+
background: var(--color-bg);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&:hover {
|
|
102
|
+
&:before {
|
|
103
|
+
background: var(--color-bg);
|
|
104
|
+
border-color: var(--color-primary);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&[disabled],
|
|
109
|
+
&.disabled {
|
|
110
|
+
&:focus,
|
|
111
|
+
&:hover {
|
|
112
|
+
color: var(--color-highlight);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&:before {
|
|
116
|
+
background: var(--color-bg);
|
|
117
|
+
border-color: var(--color-highlight);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&.button-clear {
|
|
123
|
+
color: var(--color-highlight);
|
|
124
|
+
|
|
125
|
+
&:focus,
|
|
126
|
+
&:hover {
|
|
127
|
+
color: var(--color-primary);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&[disabled],
|
|
131
|
+
&.disabled {
|
|
132
|
+
&:focus,
|
|
133
|
+
&:hover {
|
|
134
|
+
color: var(--color-highlight);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&.loading:after {
|
|
140
|
+
content: "";
|
|
141
|
+
display: block;
|
|
142
|
+
position: absolute;
|
|
143
|
+
top: 0;
|
|
144
|
+
left: 0;
|
|
145
|
+
width: 20%;
|
|
146
|
+
height: 100%;
|
|
147
|
+
opacity: 0.4;
|
|
148
|
+
background: linear-gradient(to right, transparent, var(--color-text) 50%, transparent);
|
|
149
|
+
transform: skew(-20deg) translateX(0);
|
|
150
|
+
animation: loading-button 3s infinite ease-in-out;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@keyframes loading-button {
|
|
155
|
+
0% {
|
|
156
|
+
left: 0;
|
|
157
|
+
}
|
|
158
|
+
50% {
|
|
159
|
+
left: 80%;
|
|
160
|
+
}
|
|
161
|
+
100% {
|
|
162
|
+
left: 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@media (max-width: $responsive-mobile-browser-width) {
|
|
167
|
+
button,
|
|
168
|
+
.button {
|
|
169
|
+
&.stackable {
|
|
170
|
+
display: block;
|
|
171
|
+
width: 100%;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
174
|
}
|
package/controls/code-block.js
CHANGED
|
@@ -1,35 +1,43 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import cn from 'classnames'
|
|
4
|
-
import hljs from 'highlight.js/lib/core'
|
|
5
|
-
import jsLang from 'highlight.js/lib/languages/javascript'
|
|
6
|
-
import jsonLang from 'highlight.js/lib/languages/json'
|
|
7
|
-
import xmlLang from 'highlight.js/lib/languages/xml'
|
|
8
|
-
import plaintextLang from 'highlight.js/lib/languages/plaintext'
|
|
9
|
-
import tomlLang from 'highlight.js/lib/languages/ini'
|
|
10
|
-
import rustLang from 'highlight.js/lib/languages/rust'
|
|
11
|
-
import './code-block.scss'
|
|
12
|
-
|
|
13
|
-
hljs.registerLanguage('js', jsLang)
|
|
14
|
-
hljs.registerLanguage('json', jsonLang)
|
|
15
|
-
hljs.registerLanguage('html', xmlLang)
|
|
16
|
-
hljs.registerLanguage('xml', xmlLang)
|
|
17
|
-
hljs.registerLanguage('plain', plaintextLang)
|
|
18
|
-
hljs.registerLanguage('toml', tomlLang)
|
|
19
|
-
hljs.registerLanguage('rust', rustLang)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import cn from 'classnames'
|
|
4
|
+
import hljs from 'highlight.js/lib/core'
|
|
5
|
+
import jsLang from 'highlight.js/lib/languages/javascript'
|
|
6
|
+
import jsonLang from 'highlight.js/lib/languages/json'
|
|
7
|
+
import xmlLang from 'highlight.js/lib/languages/xml'
|
|
8
|
+
import plaintextLang from 'highlight.js/lib/languages/plaintext'
|
|
9
|
+
import tomlLang from 'highlight.js/lib/languages/ini'
|
|
10
|
+
import rustLang from 'highlight.js/lib/languages/rust'
|
|
11
|
+
import './code-block.scss'
|
|
12
|
+
|
|
13
|
+
hljs.registerLanguage('js', jsLang)
|
|
14
|
+
hljs.registerLanguage('json', jsonLang)
|
|
15
|
+
hljs.registerLanguage('html', xmlLang)
|
|
16
|
+
hljs.registerLanguage('xml', xmlLang)
|
|
17
|
+
hljs.registerLanguage('plain', plaintextLang)
|
|
18
|
+
hljs.registerLanguage('toml', tomlLang)
|
|
19
|
+
hljs.registerLanguage('rust', rustLang)
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Syntax-highlighted code block using highlight.js
|
|
23
|
+
* @param {Object} props
|
|
24
|
+
* @param {string} props.children - Source code text
|
|
25
|
+
* @param {'js'|'json'|'html'|'xml'|'toml'|'rust'|'plain'} [props.lang] - Language for syntax highlighting
|
|
26
|
+
* @param {string} [props.className] - Additional CSS classes
|
|
27
|
+
* @param {Object} [props.style] - Inline styles
|
|
28
|
+
*/
|
|
29
|
+
export const CodeBlock = React.memo(function CodeBlock({children, lang, className, style}) {
|
|
30
|
+
if (lang) {
|
|
31
|
+
lang = lang.split(',')
|
|
32
|
+
}
|
|
33
|
+
const languageFilter = lang || ['js', 'json']
|
|
34
|
+
const highlighted = hljs.highlightAuto(children, languageFilter)
|
|
35
|
+
return <pre dangerouslySetInnerHTML={{__html: highlighted.value}} className={cn('hljs', className)} style={style}/>
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
CodeBlock.propTypes = {
|
|
39
|
+
children: PropTypes.string.isRequired,
|
|
40
|
+
lang: PropTypes.oneOf(['js', 'json', 'html', 'xml', 'toml', 'rust', 'plain']),
|
|
41
|
+
className: PropTypes.string,
|
|
42
|
+
style: PropTypes.object
|
|
35
43
|
}
|