Skip to content

Commit

Permalink
feat(core/input-group): migrate to shadow dom (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielleroux authored Aug 7, 2023
1 parent 955180a commit 9c9cb0e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 52 deletions.
2 changes: 1 addition & 1 deletion packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5276,7 +5276,7 @@
"usage": {},
"docs": "",
"docsTags": [],
"encapsulation": "scoped",
"encapsulation": "shadow",
"dependents": [],
"dependencies": [],
"dependencyGraph": {},
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/components/input-group/input-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
@import 'mixins/shadow-dom/component';

:host {
@include ix-component;

position: relative;
display: flex;
flex-wrap: wrap;
Expand All @@ -24,11 +27,13 @@
.group-start {
left: 0px;
height: 2rem;
margin-left: 0.375rem;
}

.group-end {
right: 0px;
height: 2rem;
margin-right: 0.375rem;
}

::slotted(*) {
Expand Down
18 changes: 10 additions & 8 deletions packages/core/src/components/input-group/input-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,27 @@ import { Component, Element, h, Host } from '@stencil/core';
@Component({
tag: 'ix-input-group',
styleUrl: 'input-group.scss',
scoped: true,
shadow: true,
})
export class InputGroup {
@Element() host!: HTMLIxInputGroupElement;
@Element() hostElement!: HTMLIxInputGroupElement;

componentDidRender() {
let paddingRight = 15;
let paddingLeft = 15;
this.host.querySelectorAll('[slot="input-end"]').forEach((item) => {
this.hostElement.querySelectorAll('[slot="input-end"]').forEach((item) => {
item.classList.add('input-group-label');
paddingRight += item.getBoundingClientRect().width;
});

this.host.querySelectorAll('[slot="input-start"]').forEach((item) => {
item.classList.add('input-group-label');
paddingLeft += item.getBoundingClientRect().width;
});
this.hostElement
.querySelectorAll('[slot="input-start"]')
.forEach((item) => {
item.classList.add('input-group-label');
paddingLeft += item.getBoundingClientRect().width;
});

const inputElement = this.host.querySelector(
const inputElement = this.hostElement.querySelector(
'input.form-control'
) as HTMLInputElement;

Expand Down
43 changes: 0 additions & 43 deletions packages/core/src/components/input-group/test/input-group.spec.tsx

This file was deleted.

0 comments on commit 9c9cb0e

Please sign in to comment.