Skip to content

Commit

Permalink
add js to input container instead
Browse files Browse the repository at this point in the history
  • Loading branch information
rmccar committed Nov 9, 2023
1 parent fbd96f9 commit d4ff7c0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/card/_card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
& > .ons-card__title {
margin-bottom: 0;
}
}
}

&__link:hover {
text-decoration-thickness: 3px;
Expand Down
2 changes: 1 addition & 1 deletion src/components/input/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
{% set prefixClass = " ons-input-type--prefix" %}
{% endif %}

<span class="ons-input-type{{ prefixClass }}">
<span class="ons-input-type{{ prefixClass }}{% if params.prefix or params.suffix %} ons-js-input-container-abbr{% endif %}">
<span class="ons-input-type__inner">
{{ input | safe }}

Expand Down
6 changes: 3 additions & 3 deletions src/components/input/input.dom.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import domready from '../../js/domready';

domready(async () => {
const abbrInputs = [...document.querySelectorAll('.ons-js-input-abbr')];
const abbrInputs = [...document.querySelectorAll('.ons-js-input-container-abbr')];

if (abbrInputs.length) {
const abbr = (await import('./input')).default;
const abbrInput = (await import('./input')).default;

abbrInputs.forEach((element) => new abbr(element));
abbrInputs.forEach((element) => new abbrInput(element));
}
});
8 changes: 4 additions & 4 deletions src/components/input/input.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export default class Abbr {
export default class AbbrInput {
constructor(context) {
this.abbr = context;
this.abbrInput = context;
this.bindEventListeners();
}

bindEventListeners() {
this.abbr.addEventListener('click', this.handleClick.bind(this));
this.abbrInput.querySelector('.ons-js-input-abbr').addEventListener('click', this.handleClick.bind(this));
}

handleClick() {
this.abbr.parentNode.querySelector('.ons-input').focus();
this.abbrInput.querySelector('.ons-input').focus();
}
}
6 changes: 2 additions & 4 deletions src/scss/objects/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
@include mq(xxs, m) {
margin-top: 1.5rem;
}

}

// Adjust margin-top when .ons-page__main contains .ons-panel--error */
.ons-breadcrumbs ~ .ons-grid .ons-grid__col .ons-page__main:has(.ons-panel--error){
margin-top: 1rem;

.ons-breadcrumbs ~ .ons-grid .ons-grid__col .ons-page__main:has(.ons-panel--error) {
margin-top: 1rem;
}

.ons-page__body {
Expand Down

0 comments on commit d4ff7c0

Please sign in to comment.