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

(SP:5) Create Chip component #2901

Merged
merged 12 commits into from
Dec 3, 2024
Merged

Conversation

sandrvvu
Copy link
Contributor

@sandrvvu sandrvvu commented Nov 27, 2024

Examples of chips:
image

About types and props:
image

Added info to StoryBook
image

Added tests

src/design-system/components/chip/Chip.tsx Outdated Show resolved Hide resolved
src/design-system/components/chip/Chip.tsx Outdated Show resolved Hide resolved
src/design-system/components/chip/Chip.tsx Outdated Show resolved Hide resolved
src/design-system/components/chip/Chip.tsx Outdated Show resolved Hide resolved
tests/unit/design-system/components/Chip.spec.jsx Outdated Show resolved Hide resolved
@sandrvvu sandrvvu force-pushed the feature/2843/create-chip-component branch from 9c1d737 to d982443 Compare November 27, 2024 23:10
@sandrvvu sandrvvu changed the title Create Chip component (SP:5) Create Chip component Nov 27, 2024
src/design-system/components/chip/Chip.tsx Outdated Show resolved Hide resolved
src/design-system/components/chip/Chip.tsx Outdated Show resolved Hide resolved
src/design-system/stories/Chip.stories.tsx Outdated Show resolved Hide resolved
@Mav-Ivan
Copy link
Contributor

check Sonar issues
image

src/design-system/components/chip/Chip.tsx Outdated Show resolved Hide resolved
src/design-system/components/chip/Chip.scss Outdated Show resolved Hide resolved
src/design-system/components/chip/Chip.tsx Outdated Show resolved Hide resolved
src/design-system/components/chip/Chip.scss Outdated Show resolved Hide resolved
@sandrvvu sandrvvu force-pushed the feature/2843/create-chip-component branch from 1866d31 to b981e4c Compare November 29, 2024 11:52
@ita-social-projects ita-social-projects deleted a comment from sonarqubecloud bot Nov 29, 2024
Copy link
Contributor

@Made1ra Made1ra left a comment

Choose a reason for hiding this comment

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

Consider adding a space before return statements, but it's up to you. Also, consider fixing Pavlo's comments. Overall, nice job!

@sandrvvu
Copy link
Contributor Author

sandrvvu commented Dec 2, 2024

Quality Gate Passed Quality Gate passed

Issues 5 New issues 0 Accepted issues

Measures 0 Security Hotspots 95.9% Coverage on New Code 0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Some issues are weird, most likely due to
image

If they stay after merging - I will make a new bug and fix it already there

Comment on lines 112 to 117
const [isOpen, setIsOpen] = useState(false)
const [selectedOption, setSelectedOption] = useState<string | null>(null)

const handleSelect = (option: string) => {
setSelectedOption(option)
setIsOpen((prev) => !prev)
Copy link
Contributor

Choose a reason for hiding this comment

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

All basic components must be stateless and all logic must be implemented at the level of the parent component (the value and the function to change this value must be passed through props). Here the component is quite limited because handleSelect only changes the behavior of the component itself, but this function can perform more difficult logic (for example, API request, interaction with other components or states, etc.). That is why the component should not have its own state and any other logic,
because now the only thing it can do is simply change the states of isOpen and selectedOption and make the appropriate style changes

@sandrvvu sandrvvu merged commit 407abba into develop Dec 3, 2024
10 checks passed
@sandrvvu sandrvvu deleted the feature/2843/create-chip-component branch December 3, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(SP: 5) Create Chip component aligned with design system
5 participants