-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
1bada4d
to
0a496dc
Compare
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
src/pin-input/pin-input.style.ts
Outdated
There was a problem hiding this comment.
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; | ||
}; |
There was a problem hiding this comment.
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
src/pin-input/types.ts
Outdated
cellCount: number, | ||
value: string, | ||
displayValue: string, | ||
} |
There was a problem hiding this comment.
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)) { | ||
// | ||
} | ||
} |
There was a problem hiding this comment.
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?.(); |
There was a problem hiding this comment.
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) || |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 {}
There was a problem hiding this comment.
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; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export the types
too.
5a8bc98
to
66bb8ad
Compare
63e29f9
to
32aa7c5
Compare
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 |
This close #40 |
@hossein-nas Please resolve the conflicts of this PR. |
32aa7c5
to
26b7a33
Compare
@amir78729 @mimshins I resolved conflicts. |
@hossein-nas LGTM, thanks |
src/pin-input-cell/events.ts
Outdated
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; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 {}
This is a draft version of developing process of
Pin Input
component.closes #40