Brisanet / ion-react

Ion design system in react
https://main--63da5890a06a8f8f995110dd.chromatic.com/
MIT License
10 stars 1 forks source link

refactor: ion typography using styled-components #147

Closed danilo-moreira-brisa closed 5 months ago

danilo-moreira-brisa commented 5 months ago

Summary by CodeRabbit

coderabbitai[bot] commented 5 months ago

Walkthrough

The recent changes focus on refactoring various typography components within the Ion React library to utilize styled-components for enhanced styling flexibility. This includes updates to component exports, testing approaches, and the introduction of new utility functions and types for consistent typography management across the library.

Changes

Files Change Summary
src/components/index.ts Reordered exports of tag and typography components.
.../typography/body/*.tsx, .../typography/heading/*.tsx Refactored to use styled-components and updated props and styles. Simplified testing setup using renderWithTheme.
.../typography/utils-typography/*.ts Introduced defaultColor utility function and removed defaultSizes export.
.../stories/typography/*.tsx Updated import paths and corrected typos in Storybook configurations.

Possibly related issues

🐇🌟 Oh hooray, oh hooray, for the code that's now sleek, With styled-components so chic, our styles are unique! Swapped, tested, and neat, with colors so bright, Our typography sings, from morning till night! 🎨📜


Recent Review Details **Configuration used: CodeRabbit UI**
Commits Files that changed from the base of the PR and between 64b00156812f8204566ca662b4d4c92c570b920d and e52249c9b0d895c80b8671cc5c2bc62a585da7cc.
Files ignored due to path filters (4) * `src/components/typhography/body/__snapshots__/body.spec.tsx.snap` is excluded by `!**/*.snap` * `src/components/typhography/heading/__snapshots__/heading.spec.tsx.snap` is excluded by `!**/*.snap` * `src/components/typography/body/__snapshots__/body.spec.tsx.snap` is excluded by `!**/*.snap` * `src/components/typography/heading/__snapshots__/heading.spec.tsx.snap` is excluded by `!**/*.snap`
Files selected for processing (13) * src/components/index.ts (1 hunks) * src/components/typography/body/body.spec.tsx (3 hunks) * src/components/typography/body/body.tsx (1 hunks) * src/components/typography/body/styles.ts (1 hunks) * src/components/typography/heading/heading.spec.tsx (2 hunks) * src/components/typography/heading/heading.tsx (2 hunks) * src/components/typography/heading/styles.ts (1 hunks) * src/components/typography/typography.types.ts (1 hunks) * src/components/typography/utils-typography/defaultColor.spec.ts (1 hunks) * src/components/typography/utils-typography/defaultColor.ts (1 hunks) * src/components/typography/utils-typography/index.ts (1 hunks) * src/stories/typography/body.stories.tsx (1 hunks) * src/stories/typography/heading.stories.tsx (1 hunks)
Files skipped from review due to trivial changes (3) * src/components/typography/utils-typography/index.ts * src/stories/typography/body.stories.tsx * src/stories/typography/heading.stories.tsx
Additional comments not posted (16)
src/components/index.ts (1)
`10-11`: Swapping the export order of `tag` and `typography` components is noted. Ensure this change does not affect modules that rely on specific import orders.
Verification successful --- The verification process confirms that swapping the export order of `tag` and `typography` components in `src/components/index.ts` does not affect other modules that import these components. The imports are either handled through the main index file or directly from their respective source files, which are unaffected by the order in the index file.
Scripts Executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Check for files that specifically import `tag` or `typography` to ensure they handle the swap correctly. rg --type ts "from './(tag|typography)'" ``` Length of output: 277
src/components/typography/body/body.tsx (1)
`4-21`: Implementation of `IonBody` with default props and styled component usage looks good.
src/components/typography/heading/heading.tsx (1)
`15-17`: Renaming variables to `$color`, `$size`, and `$weight` in `IonHeading` enhances clarity and avoids potential naming conflicts. Good practice with styled-components.
src/components/typography/utils-typography/defaultColor.spec.ts (1)
`19-28`: The parameterized tests for `defaultColor` function are well-implemented, ensuring that the function behaves as expected across different scenarios.
src/components/typography/typography.types.ts (1)
`1-30`: The type definitions in `typography.types.ts`, including the use of conditional types, are well-structured and enhance type safety and clarity in component props.
src/components/typography/utils-typography/defaultColor.ts (1)
`11-28`: The implementation of `defaultColor` function with a clear mapping of typography components to their color configurations is well-done.
src/components/typography/body/styles.ts (1)
`33-41`: The styled component `Body` for `IonBody` is well-implemented, effectively using dynamic props to apply styles. Good use of styled-components.
src/components/typography/body/body.spec.tsx (1)
`33-63`: > :memo: **NOTE** > This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-60] Refactoring of `IonBody` tests to use `renderWithTheme` and the structured snapshot tests for various props ensure comprehensive testing coverage. Well done.
src/components/typography/heading/heading.spec.tsx (4)
`9-9`: LGTM! The use of `renderWithTheme` ensures that the theme context is correctly applied during tests. --- `49-49`: Ensure that the snapshots are up-to-date and accurately reflect the intended styles. --- `57-57`: Ensure that the snapshots are up-to-date and accurately reflect the intended styles. --- `65-65`: Ensure that the snapshots are up-to-date and accurately reflect the intended styles.
src/components/typography/heading/styles.ts (4)
`81-86`: LGTM! Ensure that the functions `defaultHeading` and `defaultSizes` are correctly implemented and tested. --- `88-93`: LGTM! Ensure that the functions `defaultHeading` and `defaultSizes` are correctly implemented and tested. --- `95-100`: LGTM! Ensure that the functions `defaultHeading` and `defaultSizes` are correctly implemented and tested. --- `102-107`: LGTM! Ensure that the functions `defaultHeading` and `defaultSizes` are correctly implemented and tested.
--- Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.