Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core/tile): enable shadow dom #549

Merged
merged 2 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8325,7 +8325,7 @@
"usage": {},
"docs": "",
"docsTags": [],
"encapsulation": "scoped",
"encapsulation": "shadow",
"dependents": [],
"dependencies": [],
"dependencyGraph": {},
Expand Down
75 changes: 37 additions & 38 deletions packages/core/src/components/tile/tile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@

@import 'common-variables';
@import 'mixins/text-truncation';
@import 'mixins/shadow-dom/component';
@import 'mixins/fonts';

:host {
@mixin set-height($height) {
height: $height;
min-height: $height;
max-height: $height;
}
@mixin set-height($height) {
height: $height;
min-height: $height;
max-height: $height;
}

$heightSmall: 2.5rem;
$heightMedium: 5rem;
$heightBig: 10rem;
$width: 11.937rem;
$heightSmall: 2.5rem;
$heightMedium: 5rem;
$heightBig: 10rem;
$width: 11.937rem;

:host {
@include ix-component;

min-width: $width;
max-width: $width;
Expand All @@ -35,52 +39,33 @@
color: var(--theme-color-std-text);
box-shadow: var(--theme-tile--box-shadow);

&.tile-small {
@include set-height($heightSmall);
}

&.tile-medium {
@include set-height($heightMedium);
}

&.tile-big {
@include set-height($heightBig);
}

// @each $key, $value in $color-map-status {
// &.tile-#{$key} {
// background-color: #{$value};
// color: automatic-text-color($value, 65);
// }
// }

&:active,
&:focus-visible,
&:visited {
outline: none;
}

.tile-header {
display: flex;
align-items: center;

@include text-l-title;
}

.tile-header,
.tile-subheader,
.tile-content,
.tile-footer {
&:not(:empty) {
padding: 0 $default-space;
}
padding: 0 $default-space;
}

.tile-header,
.tile-subheader,
.tile-content {
flex-grow: 1;
}

.tile-header:not(:empty) {
.tile-header.has-content {
display: flex;
height: $large-control-height;
max-height: $large-control-height;
Expand All @@ -92,12 +77,26 @@
flex-grow: 0;
}

.tile-content {
flex-grow: 1;
}

.tile-footer:not(:empty) {
.tile-footer.has-content {
border-block-start: 1px solid var(--theme-color-1);
height: $large-control-height;
}
}

:host(.tile-small) {
@include set-height($heightSmall);
}

:host(.tile-medium) {
@include set-height($heightMedium);
}

:host(.tile-big) {
@include set-height($heightBig);
}

:host(:active),
:host(:focus-visible),
:host(:visited) {
outline: none;
}
28 changes: 24 additions & 4 deletions packages/core/src/components/tile/tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,29 @@
* LICENSE file in the root directory of this source tree.
*/

import { Component, h, Host, Prop } from '@stencil/core';
import { Component, Element, h, Host, Prop } from '@stencil/core';

@Component({
tag: 'ix-tile',
styleUrl: 'tile.scss',
scoped: true,
shadow: true,
})
export class Tile {
@Element() hostElement: HTMLIxTileElement;

/**
* Size of the tile - one of 'small', 'medium' or 'large'
*/
@Prop() size: 'small' | 'medium' | 'big' = 'medium';

hasHeaderSlot: boolean;
hasFooterSlot: boolean;

componentWillLoad() {
this.hasHeaderSlot = !!this.hostElement.querySelector('[slot="header"]');
christopher-bergwein-siemens marked this conversation as resolved.
Show resolved Hide resolved
this.hasFooterSlot = !!this.hostElement.querySelector('[slot="footer"]');
}

render() {
return (
<Host
Expand All @@ -29,7 +39,12 @@ export class Tile {
'tile-big': this.size === 'big',
}}
>
<div class="tile-header text-l-title">
<div
class={{
'tile-header': true,
'has-content': this.hasHeaderSlot,
}}
>
<slot name="header"></slot>
</div>
<div class="tile-subheader">
Expand All @@ -38,7 +53,12 @@ export class Tile {
<div class="tile-content">
<slot></slot>
</div>
<div class="tile-footer">
<div
class={{
'tile-footer': true,
'has-content': this.hasFooterSlot,
}}
>
<slot name="footer"></slot>
</div>
</Host>
Expand Down