|
| 1 | +import {LitElement, css, html} from 'lit' |
| 2 | +import {customElement} from 'lit/decorators.js' |
| 3 | + |
| 4 | + |
| 5 | +@customElement('uie-box-dashboard') |
| 6 | +export default class UieBoxDashboard extends LitElement { |
| 7 | + |
| 8 | + render() { |
| 9 | + return html` |
| 10 | + <div class="container"> |
| 11 | + ${this.renderIntroSection()} |
| 12 | + ${this.renderHeadlineSection()} |
| 13 | + ${this.renderHeaderSection()} |
| 14 | + ${this.renderHeaderActionsSection()} |
| 15 | + </div> |
| 16 | + ` |
| 17 | + } |
| 18 | + |
| 19 | + renderIntroSection() { |
| 20 | + return html` |
| 21 | + <uui-box class="red-outline" .headline="test"> |
| 22 | + <h3 slot="headline" class="blue-outline spacing headline"> |
| 23 | + this is a headline |
| 24 | + </h3> |
| 25 | + <div slot="header" class="header purple-outline spacing"> |
| 26 | + this is a header |
| 27 | + </div> |
| 28 | + <div class="header-actions pink-outline" slot="header-actions"> |
| 29 | + <uui-button href="https://uui.umbraco.com/?path=/docs/uui-box--docs" target="_blank" look="primary" |
| 30 | + color="positive"> |
| 31 | + <uui-badge slot="extra" label="A11Y label">!</uui-badge> |
| 32 | + <uui-icon name="info"></uui-icon> |
| 33 | + View the Storybook library |
| 34 | + </uui-button> |
| 35 | + </div> |
| 36 | + <slot> |
| 37 | + <div class="green-outline spacing"> |
| 38 | + <umb-code-block language="HTML">${this.renderBoxCodeExample()}</umb-code-block> |
| 39 | + <div> |
| 40 | + <p> |
| 41 | + The uui-box has largely replaces the umb-box element from previous versions of Umbraco. |
| 42 | + </p> |
| 43 | + <p> |
| 44 | + The <span class="red">uui-box</span> element (outlined in red) is used as a wrapper for |
| 45 | + boxes in Umbraco. It contains a <span class="blue">headline</span> (outlined in blue), |
| 46 | + <span class="purple">header</span> (outlined in purple), <span class="pink">header-actions</span> |
| 47 | + (outlined in pink) and <span class="green">content</span> slot (outlined in green) that |
| 48 | + are described below in more detail. |
| 49 | + </p> |
| 50 | + </div> |
| 51 | + </div> |
| 52 | + </slot> |
| 53 | + </uui-box> |
| 54 | + ` |
| 55 | + } |
| 56 | + |
| 57 | + renderHeadlineSection() { |
| 58 | + return html` |
| 59 | + <uui-box> |
| 60 | + <h3 slot="headline"> |
| 61 | + The uui-box headline slot |
| 62 | + </h3> |
| 63 | + <slot> |
| 64 | + <div> |
| 65 | + <umb-code-block language="HTML">${this.renderHeadlineSlotCodeExample()}</umb-code-block> |
| 66 | + </div> |
| 67 | + <p> |
| 68 | + The headline slot is optional and is used to display a title for the box. |
| 69 | + </p> |
| 70 | +
|
| 71 | + <div> |
| 72 | + <umb-code-block language="HTML">${this.renderHeadlineAttributeCodeExample()}</umb-code-block> |
| 73 | + </div> |
| 74 | + <p> |
| 75 | + Alternatively, you can use the headline attribute to set the title of the box. And the headline-variant attribute to set the variant of the headline. |
| 76 | + </p> |
| 77 | + </slot> |
| 78 | + </uui-box> |
| 79 | + `; |
| 80 | + } |
| 81 | + |
| 82 | + renderHeaderSection(){ |
| 83 | + return html` |
| 84 | + <uui-box> |
| 85 | + |
| 86 | + <h3 slot="headline"> |
| 87 | + The uui-box header slot |
| 88 | + </h3> |
| 89 | + <slot> |
| 90 | + <div> |
| 91 | + <umb-code-block language="HTML">${this.renderHeaderSlotCodeExample()}</umb-code-block> |
| 92 | + <p> |
| 93 | + The header slot is optional and is used to display additional content in the header of the |
| 94 | + box. |
| 95 | + </p> |
| 96 | + </div> |
| 97 | + </slot> |
| 98 | + </uui-box> |
| 99 | + `; |
| 100 | + } |
| 101 | + |
| 102 | + renderHeaderActionsSection(){ |
| 103 | + return html` |
| 104 | + <uui-box> |
| 105 | + <h3 slot="headline"> |
| 106 | + The uui-box header-actions slot |
| 107 | + </h3> |
| 108 | + <slot> |
| 109 | + <div> |
| 110 | + <umb-code-block language="HTML">${this.renderHeaderActionsSlotCodeExample()}</umb-code-block> |
| 111 | + <p> |
| 112 | + The header-actions slot is optional and is used to display actions such as buttons and links in the header of the box. |
| 113 | + </p> |
| 114 | + </div> |
| 115 | + </slot> |
| 116 | + </uui-box> |
| 117 | + `; |
| 118 | + } |
| 119 | + |
| 120 | + renderBoxCodeExample() { |
| 121 | + return html` |
| 122 | +<uui-box> |
| 123 | + <h3 slot="headline"> |
| 124 | + this is a headline |
| 125 | + </h3> |
| 126 | + <div slot="header"> |
| 127 | + this is a header |
| 128 | + </div> |
| 129 | + <div slot="header-actions"> |
| 130 | + // header actions here |
| 131 | + </div> |
| 132 | + <slot> |
| 133 | + // content here |
| 134 | + </slot> |
| 135 | +</uui-box> |
| 136 | + `; |
| 137 | + } |
| 138 | + |
| 139 | + renderHeadlineSlotCodeExample() { |
| 140 | + return html` |
| 141 | +<h3 slot="headline"> |
| 142 | + This is a headline |
| 143 | +</h3> |
| 144 | + ` |
| 145 | + } |
| 146 | + renderHeadlineAttributeCodeExample() { |
| 147 | + return html` |
| 148 | +<uui-box headline="This is a headline" headline-variant="h3"> |
| 149 | +</uui-box> |
| 150 | + ` |
| 151 | + } |
| 152 | + |
| 153 | + renderHeaderActionsSlotCodeExample() { |
| 154 | + return html` |
| 155 | +<div slot="header-actions"> |
| 156 | + // header actions here / buttons / links / etc |
| 157 | + <uui-button href="https://umbraco.com/" target="_blank" look="primary"color="positive"> |
| 158 | + <uui-badge slot="extra" label="A11Y label">!</uui-badge> |
| 159 | + <uui-icon name="info"></uui-icon> |
| 160 | + I am a button link |
| 161 | + </uui-button> |
| 162 | +</div> |
| 163 | + ` |
| 164 | + } |
| 165 | + |
| 166 | + |
| 167 | + renderHeaderSlotCodeExample() { |
| 168 | + return html` |
| 169 | +<div slot="header"> |
| 170 | + This is a header |
| 171 | +</div> |
| 172 | + ` |
| 173 | + } |
| 174 | + |
| 175 | + static styles = css` |
| 176 | + :host { |
| 177 | + padding: var(--uui-size-layout-1); |
| 178 | + display: block; |
| 179 | +
|
| 180 | + --border-size: 2px; |
| 181 | + } |
| 182 | +
|
| 183 | + :host * { |
| 184 | + box-sizing: border-box; |
| 185 | + } |
| 186 | +
|
| 187 | + .header-actions { |
| 188 | + display: flex; |
| 189 | + padding: var(--uui-size-space-5); |
| 190 | + height: 100%; |
| 191 | +
|
| 192 | + } |
| 193 | +
|
| 194 | + .header-actions uui-button { |
| 195 | + height: min-content; |
| 196 | + align-self: center; |
| 197 | + } |
| 198 | +
|
| 199 | + .container { |
| 200 | + display: flex; |
| 201 | + flex-direction: column; |
| 202 | + gap: var(--uui-size-space-5); |
| 203 | + } |
| 204 | +
|
| 205 | + .spacing { |
| 206 | + padding: var(--uui-size-space-5); |
| 207 | + } |
| 208 | +
|
| 209 | + .headline { |
| 210 | + height: 100%; |
| 211 | + margin: 0; |
| 212 | + } |
| 213 | +
|
| 214 | + .header { |
| 215 | + display: flex; |
| 216 | + align-items: center; |
| 217 | + } |
| 218 | +
|
| 219 | + .red-outline { |
| 220 | + border: var(--border-size) solid red; |
| 221 | + } |
| 222 | +
|
| 223 | + .blue-outline { |
| 224 | + border: var(--border-size) solid blue; |
| 225 | + } |
| 226 | +
|
| 227 | + .green-outline { |
| 228 | + border: var(--border-size) solid green; |
| 229 | + } |
| 230 | +
|
| 231 | + .purple-outline { |
| 232 | + border: var(--border-size) solid purple; |
| 233 | + } |
| 234 | +
|
| 235 | + .pink-outline { |
| 236 | + border: var(--border-size) solid hotpink; |
| 237 | + } |
| 238 | +
|
| 239 | + .red { |
| 240 | + color: red; |
| 241 | + } |
| 242 | +
|
| 243 | + .blue { |
| 244 | + color: blue; |
| 245 | + } |
| 246 | +
|
| 247 | + .green { |
| 248 | + color: green; |
| 249 | + } |
| 250 | +
|
| 251 | + .purple { |
| 252 | + color: purple; |
| 253 | + } |
| 254 | +
|
| 255 | + .pink { |
| 256 | + color: hotpink; |
| 257 | + } |
| 258 | + `; |
| 259 | +} |
| 260 | + |
| 261 | +declare global { |
| 262 | + interface HTMLElementTagNameMap { |
| 263 | + 'UieBoxDashboard': UieBoxDashboard |
| 264 | + } |
| 265 | +} |
0 commit comments