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

refactor(elements): ino-input/select add dense #1114

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
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
8 changes: 4 additions & 4 deletions packages/elements-angular/src/directives/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,15 +515,15 @@ export declare interface InoImgList extends Components.InoImgList {}


@ProxyCmp({
inputs: ['autoFocus', 'autocomplete', 'dataList', 'disabled', 'error', 'helper', 'helperCharacterCounter', 'helperPersistent', 'helperValidation', 'label', 'max', 'maxlength', 'min', 'name', 'outline', 'pattern', 'placeholder', 'required', 'showLabelHint', 'step', 'type', 'unit', 'value'],
inputs: ['autoFocus', 'autocomplete', 'dataList', 'dense', 'disabled', 'error', 'helper', 'helperCharacterCounter', 'helperPersistent', 'helperValidation', 'label', 'max', 'maxlength', 'min', 'name', 'outline', 'pattern', 'placeholder', 'required', 'showLabelHint', 'step', 'type', 'unit', 'value'],
methods: ['getInputElement', 'setFocus', 'setBlur']
})
@Component({
selector: 'ino-input',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['autoFocus', 'autocomplete', 'dataList', 'disabled', 'error', 'helper', 'helperCharacterCounter', 'helperPersistent', 'helperValidation', 'label', 'max', 'maxlength', 'min', 'name', 'outline', 'pattern', 'placeholder', 'required', 'showLabelHint', 'step', 'type', 'unit', 'value'],
inputs: ['autoFocus', 'autocomplete', 'dataList', 'dense', 'disabled', 'error', 'helper', 'helperCharacterCounter', 'helperPersistent', 'helperValidation', 'label', 'max', 'maxlength', 'min', 'name', 'outline', 'pattern', 'placeholder', 'required', 'showLabelHint', 'step', 'type', 'unit', 'value'],
})
export class InoInput {
protected el: HTMLElement;
Expand Down Expand Up @@ -1048,14 +1048,14 @@ export declare interface InoSegmentGroup extends Components.InoSegmentGroup {


@ProxyCmp({
inputs: ['disabled', 'error', 'helper', 'helperPersistent', 'helperValidation', 'label', 'name', 'outline', 'required', 'showLabelHint', 'value']
inputs: ['dense', 'disabled', 'error', 'helper', 'helperPersistent', 'helperValidation', 'label', 'name', 'outline', 'required', 'showLabelHint', 'value']
})
@Component({
selector: 'ino-select',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['disabled', 'error', 'helper', 'helperPersistent', 'helperValidation', 'label', 'name', 'outline', 'required', 'showLabelHint', 'value'],
inputs: ['dense', 'disabled', 'error', 'helper', 'helperPersistent', 'helperValidation', 'label', 'name', 'outline', 'required', 'showLabelHint', 'value'],
})
export class InoSelect {
protected el: HTMLElement;
Expand Down
2 changes: 2 additions & 0 deletions packages/elements-vue/src/proxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export const InoInput = /*@__PURE__*/ defineContainer<JSX.InoInput, JSX.InoInput
'autoFocus',
'dataList',
'disabled',
'dense',
'error',
'helper',
'helperCharacterCounter',
Expand Down Expand Up @@ -455,6 +456,7 @@ export const InoSelect = /*@__PURE__*/ defineContainer<JSX.InoSelect, JSX.InoSel
'showLabelHint',
'label',
'outline',
'dense',
'value',
'helper',
'helperValidation',
Expand Down
16 changes: 16 additions & 0 deletions packages/elements/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,10 @@ export namespace Components {
* The id of the datalist child
*/
"dataList"?: string;
/**
* Makes the input text and container slightly smaller.
*/
"dense": boolean;
/**
* Disables this element.
*/
Expand Down Expand Up @@ -1323,6 +1327,10 @@ export namespace Components {
* Use the custom `ino-option` component to add options to the select component. The `label` attribute sets an optional floating label for this element.
*/
interface InoSelect {
/**
* Makes the input text and container slightly smaller.
*/
"dense": boolean;
/**
* Disables this element.
*/
Expand Down Expand Up @@ -3140,6 +3148,10 @@ declare namespace LocalJSX {
* The id of the datalist child
*/
"dataList"?: string;
/**
* Makes the input text and container slightly smaller.
*/
"dense"?: boolean;
/**
* Disables this element.
*/
Expand Down Expand Up @@ -3773,6 +3785,10 @@ declare namespace LocalJSX {
* Use the custom `ino-option` component to add options to the select component. The `label` attribute sets an optional floating label for this element.
*/
interface InoSelect {
/**
* Makes the input text and container slightly smaller.
*/
"dense"?: boolean;
/**
* Disables this element.
*/
Expand Down
72 changes: 65 additions & 7 deletions packages/elements/src/components/ino-input/ino-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ $padding-top: 24px;

$icon-padding-to-text: 12px;
$icon-padding-to-border: 6px;
$icon-padding-to-text-dense: 6px;
$icon-padding-to-bottom-dense: 15px;
$icon-padding-to-border-dense: 0px;

$filled-input-height: 56px;
$filled-input-height-dense: 30px;
$filled-input-padding-dense: calc($padding-top - 22px) 0 0;
$filled-selected-text-height-dense: 25px;

$outline-input-height: 40px;
$outline-input-height-dense: 30px;
$outline-shape-radius: $outline-input-height / 2;
$outline-shape-radius-corner: $outline-shape-radius $outline-shape-radius
$outline-shape-radius 0;
Expand Down Expand Up @@ -80,7 +89,7 @@ ino-input {

.mdc-text-field {
@include textfield.ink-color(var(--input-color));
@include textfield.height(56px);
@include textfield.height($filled-input-height);
}

& * {
Expand Down Expand Up @@ -130,7 +139,6 @@ ino-input .mdc-text-field--filled {
@include textfield.fill-color(transparent);
@include textfield.disabled-fill-color(transparent);
@include textfield.line-ripple-color(var(--input-line-color));

&.mdc-text-field--invalid {
@include textfield.line-ripple-color(theme.$error);
}
Expand Down Expand Up @@ -173,11 +181,51 @@ ino-input .mdc-text-field--filled {
);
}

// filled dense
ino-input .mdc-text-field--filled.ino-input--dense {
@include textfield.density(-1);
@include textfield.height($filled-input-height-dense);
align-items: end;
overflow: visible;

.mdc-text-field__input {
padding: $filled-input-padding-dense;
height: $filled-selected-text-height-dense;
}

.mdc-floating-label {
display: unset;
padding-bottom: 2px;
}

.mdc-floating-label.mdc-floating-label--float-above {
margin-top: 3px;
}

&:has(.mdc-text-field__icon.mdc-text-field__icon--leading) {
@include setIconMargins(
(
0 $icon-padding-to-text-dense $icon-padding-to-bottom-dense
$icon-padding-to-border-dense
),
(
0 $icon-padding-to-border-dense $icon-padding-to-bottom-dense
$icon-padding-to-text-dense
)
);
.mdc-floating-label,
.mdc-floating-label--float-above {
left: 21px;
}
}
}

// Outlined textfield specific
ino-input .mdc-text-field--outlined {
@include textfield.focused-outline-color(var(--input-line-color));
@include textfield.outline-shape-radius(20px);
@include textfield.outlined-height($outline-input-height);
@include setIconMargins((0 $icon-padding-to-text 0 $icon-padding-to-text));

border-style: none !important;

Expand Down Expand Up @@ -208,16 +256,26 @@ ino-input .mdc-text-field--outlined {
height: 16px;
width: 16px;
}

@include setIconMargins((0 $icon-padding-to-text 0 $icon-padding-to-text));
}

ino-input {
.mdc-text-field + .mdc-text-field-helper-line {
padding-left: 0;
// outlined dense
ino-input .mdc-text-field--outlined.ino-input--dense {
@include textfield.outlined-height($outline-input-height-dense);

&[class*='--with-leading-icon'] .mdc-floating-label {
left: 21px;
}

&[class*='--with-leading-icon']
.mdc-floating-label.mdc-floating-label--float-above {
left: 5px;
}
}

ino-input .mdc-text-field + .mdc-text-field-helper-line {
padding-left: 0;
}

// Custom number arrows
ino-input[type='number'] {
@include hideNativeNumberInputArrows();
Expand Down
6 changes: 6 additions & 0 deletions packages/elements/src/components/ino-input/ino-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export class Input implements ComponentInterface {
*/
@Prop() disabled?: boolean;

/**
* Makes the input text and container slightly smaller.
*/
@Prop() dense = false;

/**
* Displays the input field as invalid if set to true.
* If the property is not set or set to false, the validation is handled by the `pattern` property.
Expand Down Expand Up @@ -469,6 +474,7 @@ export class Input implements ComponentInterface {

const classTextfield = classNames({
'ino-input__composer': true,
'ino-input--dense': this.dense,
'mdc-text-field': true,
'mdc-text-field--disabled': this.disabled,
'mdc-text-field--focused': this.autoFocus,
Expand Down
1 change: 1 addition & 0 deletions packages/elements/src/components/ino-input/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Use this element for **simple types** like `text`, `password`, `number` or `emai
| `autoFocus` | `auto-focus` | The autofocus of this element. | `boolean` | `undefined` |
| `autocomplete` | `autocomplete` | The autocomplete property of this element. | `string` | `undefined` |
| `dataList` | `data-list` | The id of the datalist child | `string` | `undefined` |
| `dense` | `dense` | Makes the input text and container slightly smaller. | `boolean` | `false` |
| `disabled` | `disabled` | Disables this element. | `boolean` | `undefined` |
| `error` | `error` | Displays the input field as invalid if set to true. If the property is not set or set to false, the validation is handled by the `pattern` property. This functionality might be useful if the input validation is (additionally) handled by the backend. | `boolean` | `undefined` |
| `helper` | `helper` | The optional helper text. | `string` | `undefined` |
Expand Down
Loading
Loading