-
Notifications
You must be signed in to change notification settings - Fork 0
feat(CounterField): new component #335
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
Open
HaykKirakosyanSoft
wants to merge
30
commits into
release/3.0.0
Choose a base branch
from
feature/add-counter-field-component
base: release/3.0.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
545257b
feat(CounterField): component boilerplate
HaykKirakosyanSoft 99fccd6
feat: adding some UI parts
HaykKirakosyanSoft 9804c29
feat: working on component stories
HaykKirakosyanSoft e3db389
feat: working on component styles
HaykKirakosyanSoft d52615c
feat: adding logic
HaykKirakosyanSoft 9df68c3
feat: adding tests and controlled/uncontrolled logics
HaykKirakosyanSoft 3e0a47f
fix: fixed the conflicts
HaykKirakosyanSoft 70c75b5
fix(CounterField): removed all the comments from .scss file
HaykKirakosyanSoft 5ec5da9
fix(CounterField): removed all unnecessary designs
HaykKirakosyanSoft a8329ec
fix(CounterField): fixed the aria-labels
HaykKirakosyanSoft ad823d4
fix(CounterField): corrected onBlur,onFocus names,and removed tabIndex
HaykKirakosyanSoft 847eb78
fix(CounterField): added //Components comment and moved export to the…
HaykKirakosyanSoft 883a2bf
fix(CounterField): added max logic for consistent API
HaykKirakosyanSoft 70888e8
fix(CounterField): removed spaces and wrapper
HaykKirakosyanSoft e9812aa
fix(CounterField): removed React namespace and number type
HaykKirakosyanSoft 6e0551c
fix(CounterField): removed the tests for tabIndex
HaykKirakosyanSoft fa76b7a
Merge branch 'release/3.0.0' of github.com:softconstruct/gene-ui-comp…
GaroGabrielyan 53a3b4e
fix(CounterField): removed unused styles
HaykKirakosyanSoft 8c78b33
Merge branch 'feature/add-counter-field-component' of github.com:soft…
HaykKirakosyanSoft aa3d426
fix(CounterField): removed comments from test.tsx
HaykKirakosyanSoft 11613e0
feat(CounterField): label onclick activates the input
HaykKirakosyanSoft f7952e6
fix(CounterField): removed readonly prop
HaykKirakosyanSoft 2835aa1
Merge remote-tracking branch 'origin/release/3.0.0' into feature/add-…
HaykKirakosyanSoft ccac926
feat(CounterField): removed min,max props and corresponding logic
HaykKirakosyanSoft 2dbf5c5
feat(CounterField): refactored code to work correctly with non numeri…
HaykKirakosyanSoft 41095b0
feat(CounterField): refactored controlled story
HaykKirakosyanSoft 574994f
feat(CounterField): updated the stories accordingly to new changes
HaykKirakosyanSoft 2406d21
Merge branch 'release/3.0.0' of github.com:softconstruct/gene-ui-comp…
GaroGabrielyan 8ad5eea
feat(CounterField): added readOnly prop and tests to the component
HaykKirakosyanSoft 832a589
Merge branch 'feature/add-counter-field-component' of github.com:soft…
HaykKirakosyanSoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| .counterField { | ||
| $this: &; | ||
|
|
||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: flex-start; | ||
| gap: var(--guit-ref-spacing-3xsmall); | ||
|
|
||
| &__inputContainer { | ||
| display: flex; | ||
| gap: var(--guit-ref-spacing-xsmall); | ||
| width: 100%; | ||
HaykKirakosyanSoft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| &__input { | ||
| width: 8rem; | ||
| } | ||
|
|
||
| &__infoContainer { | ||
HaykKirakosyanSoft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| display: flex; | ||
| width: 100%; | ||
| } | ||
|
|
||
| &_readOnly { | ||
| pointer-events: none; | ||
| } | ||
| } | ||
77 changes: 77 additions & 0 deletions
77
src/components/molecules/CounterField/CounterField.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import React, { ChangeEvent, FC, MouseEvent, useState } from "react"; | ||
| import { Meta, StoryObj } from "@storybook/react"; | ||
|
|
||
| // Components | ||
| import CounterField, { ICounterFieldProps } from "@components/molecules/CounterField/CounterField"; | ||
|
|
||
| // Helpers | ||
| import { args, propCategory } from "../../../../stories/assets/storybook.globals"; | ||
|
|
||
| const meta: Meta<ICounterFieldProps> = { | ||
| title: "Molecules/CounterField", | ||
| component: CounterField, | ||
| argTypes: { | ||
| value: args({ control: "text", ...propCategory.states }), | ||
| defaultValue: args({ control: "number", ...propCategory.states }), | ||
| disabled: args({ control: "boolean", ...propCategory.states }), | ||
| readOnly: args({ control: "boolean", ...propCategory.states }), | ||
| ariaLabelIncrement: args({ control: "text", ...propCategory.others }), | ||
| ariaLabelDecrement: args({ control: "text", ...propCategory.others }), | ||
| step: args({ control: "number", defaultValue: 1, ...propCategory.validation }), | ||
| size: args({ control: "select", ...propCategory.appearance }), | ||
| status: args({ control: "select", ...propCategory.appearance }), | ||
| className: args({ control: "false", ...propCategory.appearance }), | ||
| label: args({ control: "text", ...propCategory.content }), | ||
| infoText: args({ control: "text", ...propCategory.content }), | ||
| helperText: args({ control: "text", ...propCategory.content }), | ||
| required: args({ control: "boolean", ...propCategory.states }), | ||
| onChange: args({ control: "false", ...propCategory.action }), | ||
| onInputBlur: args({ control: "false", ...propCategory.action }), | ||
| onInputFocus: args({ control: "false", ...propCategory.action }) | ||
| }, | ||
|
|
||
| args: { | ||
| defaultValue: 0, | ||
| step: 1, | ||
| size: "medium", | ||
| status: "rest", | ||
| label: "Label", | ||
| helperText: "Helper text", | ||
| required: true | ||
| } | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<ICounterFieldProps>; | ||
|
|
||
| const Template: FC<ICounterFieldProps> = ({ ...props }) => <CounterField {...props} />; | ||
|
|
||
| export const Default: Story = { | ||
| render: ({ ...props }) => <Template {...props} />, | ||
| argTypes: { value: args({ control: "false", ...propCategory.states }) } | ||
| }; | ||
|
|
||
| const ControlledTemplate: FC<ICounterFieldProps> = ({ value, onChange, ...props }) => { | ||
| const isControlled = value !== undefined; | ||
| const displayValue = isControlled ? value : "0"; | ||
| const [internalStringValue, setInternalStringValue] = useState(displayValue); | ||
|
|
||
| const handleChange = ( | ||
| newValueString: string, | ||
| event: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLButtonElement> | ||
| ) => { | ||
| setInternalStringValue(newValueString); | ||
| onChange?.(newValueString, event); | ||
| }; | ||
|
|
||
| return <CounterField {...props} value={internalStringValue} onChange={handleChange} />; | ||
| }; | ||
|
|
||
| export const Controlled: Story = { | ||
| render: (props) => <ControlledTemplate {...props} />, | ||
| args: { | ||
| helperText: "Controlled Counter" | ||
| }, | ||
| argTypes: { defaultValue: args({ control: "false", ...propCategory.states }) } | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There is no token for this gap , please clarify with designer
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 saw it on figma, also when you remove this token the gap between label,buttons and input breaks.