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: develop pin-input #91

Closed
wants to merge 9 commits into from

Conversation

hossein-nas
Copy link
Collaborator

@hossein-nas hossein-nas commented May 8, 2024

This is a draft version of developing process of Pin Input component.

closes #40

@hossein-nas hossein-nas force-pushed the feat/develop-pin-input branch 3 times, most recently from 1bada4d to 0a496dc Compare May 11, 2024 08:05
@hossein-nas hossein-nas marked this pull request as ready for review May 11, 2024 18:04
box-sizing: border-box;
--height: var(--tap-pin-input-cell-height, 52px);
--bg-color: var(--tap-pin-input-cell-bg-color, #eaeded);
--error-bg-color: var(--tap-pin-input-cell-error-bg-color, #ffefed);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for default value use the system tokens. ex.

--error-bg-color: var(--tap-pin-input-cell-error-bg-color, --tap-sys-color-surface-negative-light);

also use the system token naming pattern for naming component tokens. ex.
--tap-sys-color-surface-negative-light -> --tap-pin-input-cell-color-surface-negative


--padding-sm: var(--tap-pin-input-cell-padding-small, 6px);
--padding-md: var(--tap-pin-input-cell-padding-medium, 8px);
--padding-lg: var(--tap-pin-input-cell-padding-large, 12px);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I think we should not define 2 different CSS properties for a single token. both --padding-lg and --tap-pin-input-cell-padding-large would have the same usage and one is redundant.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments as the pin-input-cell.style.ts

cell: PinInputCell;
index: number;
value: T;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define the whole event instead of the event params is a better practice.
also, we need to export the types in index.ts

cellCount: number,
value: string,
displayValue: string,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as pin-input-cell types

if (changed.has('value') && !Number.isNaN(this.value)) {
//
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove please

super.firstUpdated(_changedProperties);

if (this.autoFocus) {
this._cell.focus?.();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess optional chaining is unnecessary here

}

if (
[8, 9, 13, 27, 46, 110, 190].includes(event.keyCode) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event.keyCode is deprecated. use event.key instead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pin-input should be a form control element using elementInternal. so we can use the browser native auto-fill

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at with-form-associated Mixin and with-element-internals Mixin.

const BaseClass = withFormAssociated(withElementInternals(LitElement));

class PinInput extends BaseClass {}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To enhance simplicity and readability, consider moving most of the logic to the pin-input component. For instance, handling keyboard events could be consolidated within the pin-input element, rather than having both components engaged in event handling

interface HTMLElementTagNameMap {
'tap-pin-input': TapPinInput;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export the types too.

@hossein-nas hossein-nas force-pushed the feat/develop-pin-input branch from 5a8bc98 to 66bb8ad Compare July 8, 2024 04:10
@hossein-nas hossein-nas force-pushed the feat/develop-pin-input branch from 63e29f9 to 32aa7c5 Compare August 19, 2024 08:09
@hossein-nas
Copy link
Collaborator Author

I assume the development of this component is finished. @majidsajadi please review changes and let me know if there are issues or possible improvements. Thanks

@hossein-nas
Copy link
Collaborator Author

This close #40

@amir78729
Copy link
Member

@hossein-nas Please resolve the conflicts of this PR.

@hossein-nas hossein-nas force-pushed the feat/develop-pin-input branch from 32aa7c5 to 26b7a33 Compare October 14, 2024 14:08
@hossein-nas
Copy link
Collaborator Author

@amir78729 @mimshins I resolved conflicts.

@amir78729
Copy link
Member

@hossein-nas LGTM, thanks

Comment on lines 10 to 31
export class PinInputCellFilled extends Event {
public message: string;
public details: ValueChangedEventParams;

constructor(
message: string,
details: ValueChangedEventParams,
eventInitDict: EventInit = {},
) {
const _eventInitDict = {
bubbles: true,
composed: false,
...eventInitDict,
};
const type = PIN_INPUT_CELL_FILLED_TYPE;
super(type, _eventInitDict);

this.details = details;
this.message = message;
}
}

Copy link
Collaborator

@mimshins mimshins Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a utility BaseEvent you can use to write your own custom events.

For naming conventions of custom events, I recommend omitting the component name, as the component is already encapsulated within its own directory.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at with-form-associated Mixin and with-element-internals Mixin.

const BaseClass = withFormAssociated(withElementInternals(LitElement));

class PinInput extends BaseClass {}

@hossein-nas hossein-nas marked this pull request as draft October 30, 2024 16:02
@mimshins mimshins closed this Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(pin-input): add PinInput component
4 participants