-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add linksCn (links className helper) to UI-Kit #1024
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 WalkthroughWalkthroughThis pull request introduces a Changes
Possibly Related PRs
Suggested Labels
Suggested Reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Visit the preview URL for this PR (updated for commit 6b0c969): https://si-admin-staging--pr1024-almsh-uikit-links-cljf3ycc.web.app (expires Wed, 19 Feb 2025 10:26:20 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: b7b0969384059dce6ea8fad1ee1d1737e54e6676 |
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.
Actionable comments posted: 3
🧹 Nitpick comments (1)
ui/src/components/typography/links.ts (1)
57-123
: Consider extending variants to support 'muted'.
You may want to add'muted'
as a value undervariant
to match usage in other files. This might prevent styling mismatches and keeps the design consistent.variants: { variant: { default: 'text-foreground ...', accent: 'text-accent ...', destructive: 'text-destructive ...', + muted: 'text-foreground/60 hover:text-foreground/80', }, ... }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
ui/src/components/typography/index.ts
(1 hunks)ui/src/components/typography/links.ts
(1 hunks)ui/src/components/typography/typography.stories.tsx
(0 hunks)ui/src/stories/links.stories.tsx
(1 hunks)ui/src/stories/typography.stories.tsx
(1 hunks)website/src/app/[lang]/[region]/(website)/transparency/evidence/section-card.tsx
(2 hunks)website/src/components/faq/faq-section.tsx
(2 hunks)
💤 Files with no reviewable changes (1)
- ui/src/components/typography/typography.stories.tsx
✅ Files skipped from review due to trivial changes (2)
- ui/src/components/typography/index.ts
- ui/src/stories/typography.stories.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Deploy admin on Firebase (social-income-staging) / Deploy admin on Firebase
- GitHub Check: Test website
<Link href={fragment.href} className={linkCn({ variant: 'muted' })}> | ||
{fragment.text} |
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.
Use a valid variant instead of 'muted'
.
The variant
field in linkCn
only supports 'default'
, 'accent'
, or 'destructive'
. Consider adding a 'muted'
variant to linkCn
or switch to a supported variant.
Example fix:
- <Link href={fragment.href} className={linkCn({ variant: 'muted' })}>
+ <Link href={fragment.href} className={linkCn({ variant: 'default' })}>
{fragment.text}
</Link>
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<Link href={fragment.href} className={linkCn({ variant: 'muted' })}> | |
{fragment.text} | |
<Link href={fragment.href} className={linkCn({ variant: 'default' })}> | |
{fragment.text} |
interface WithControlsProps { | ||
children: string; | ||
variant: 'default' | 'accent' | 'destructive'; | ||
size: 'inherit' | 'sm' | 'md' | 'lg' | 'xl' | '4xl'; | ||
underline: 'none' | 'hover' | 'always'; | ||
icon: boolean; | ||
arrow: boolean | 'external'; | ||
} |
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.
Align arrow prop type with internal usage.
Your type definition only allows boolean | 'external'
, but you're also using 'internal'
. Update the type to include 'internal'
and false
for consistency.
-interface WithControlsProps {
- arrow: boolean | 'external';
+interface WithControlsProps {
+ arrow: false | 'internal' | 'external';
// ...
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
interface WithControlsProps { | |
children: string; | |
variant: 'default' | 'accent' | 'destructive'; | |
size: 'inherit' | 'sm' | 'md' | 'lg' | 'xl' | '4xl'; | |
underline: 'none' | 'hover' | 'always'; | |
icon: boolean; | |
arrow: boolean | 'external'; | |
} | |
interface WithControlsProps { | |
children: string; | |
variant: 'default' | 'accent' | 'destructive'; | |
size: 'inherit' | 'sm' | 'md' | 'lg' | 'xl' | '4xl'; | |
underline: 'none' | 'hover' | 'always'; | |
icon: boolean; | |
arrow: false | 'internal' | 'external'; | |
} |
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
ui/src/stories/links.stories.tsx (1)
89-89
: Use getIconSizeClassByLinkSize for consistent icon sizing.Replace hardcoded icon sizes with the helper function for consistency.
-<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"> +<svg className={getIconSizeClassByLinkSize('md')} fill="none" viewBox="0 0 24 24" stroke="currentColor">Also applies to: 100-100
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
ui/src/stories/links.stories.tsx
(1 hunks)website/src/app/[lang]/[region]/(website)/transparency/evidence/section-card.tsx
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- website/src/app/[lang]/[region]/(website)/transparency/evidence/section-card.tsx
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Test shared code
- GitHub Check: Test website
- GitHub Check: Test functions
- GitHub Check: Test admin
- GitHub Check: Prettify
- GitHub Check: Security checks (typescript)
🔇 Additional comments (2)
ui/src/stories/links.stories.tsx (2)
217-224
: Fix inconsistent arrow prop types.The
arrow
prop type inWithControlsProps
doesn't match its usage inLinkStoryProps
and the actual implementation.
226-241
: Verify icon sizes for 'sm' and 'md'.Both 'sm' and 'md' sizes return 'h-3 w-3'. Please verify if this is intentional.
Also, consider adding unit tests for this helper function.
Would you like me to help generate unit tests for this function?
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth={2} | ||
d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1" | ||
/> | ||
</svg> |
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.
🛠️ Refactor suggestion
Extract duplicated SVG path to a reusable component.
The same SVG path data is duplicated in multiple places. Extract it into a reusable component to improve maintainability.
+const LinkIconSvg = ({ className }: { className: string }) => (
+ <svg className={className} fill="none" viewBox="0 0 24 24" stroke="currentColor">
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth={2}
+ d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"
+ />
+ </svg>
+);
Also applies to: 100-107, 301-308
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.
nice! I updated the className in the Links that we already used now 👍
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.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
website/src/app/[lang]/[region]/(website)/me/contributions/page.tsx (1)
22-26
: 🛠️ Refactor suggestionRemove redundant styling layers.
Using both linkCn and Button component creates unnecessary style layering. Consider using either:
- Just the Button component for interaction
- Just Link with linkCn for navigation
-<Link className={linkCn()} href={`/${lang}/${region}/donate/one-time`}> - <Button Icon={PlusCircleIcon} variant="ghost" size="lg" className="w-full"> - {translator.t('contributions.one-time-payment')} - </Button> -</Link> +<Button + as={Link} + href={`/${lang}/${region}/donate/one-time`} + Icon={PlusCircleIcon} + variant="ghost" + size="lg" + className="w-full" +> + {translator.t('contributions.one-time-payment')} +</Button>
🧹 Nitpick comments (7)
website/src/app/[lang]/[region]/(website)/arts/section-card.tsx (1)
4-4
: Consider customizing linkCn for complex link structure.The default linkCn configuration might not be optimal for a link containing an icon and text. Consider specifying variants and options.
-<Link className={linkCn()} href={link.href} target="_blank"> +<Link className={linkCn({ variant: 'primary', icon: true })} href={link.href} target="_blank">Also applies to: 32-32
website/src/app/[lang]/[region]/(website)/books/section-1.tsx (1)
23-23
: Add email variant to linkCn.Use the email variant for consistent styling of email links.
-<Link className={linkCn()} href="mailto: [email protected]"> +<Link className={linkCn({ variant: 'email' })} href="mailto: [email protected]">website/src/app/[lang]/[region]/(blue-theme)/donate/individual/page.tsx (1)
32-36
: Remove duplicate hover styling.The parent div's
hover:underline
class conflicts withlinkCn
's hover behavior.-<div className="mt-4 hover:underline"> +<div className="mt-4"> <Link className={linkCn()} href={`/${lang}/${region}/donate/one-time`}> {translator.t('one-time-donation')} </Link> </div>website/src/app/[lang]/[region]/(website)/app/page.tsx (1)
31-38
: Add store variant to linkCn.Store links should use a specific variant for consistent styling across the application.
<Link - className={linkCn()} + className={linkCn({ variant: 'store' })} href="https://play.google.com/store/apps/details?id=org.socialincome.app" target="_blank" rel="noopener noreferrer" >Apply the same change to the Apple Store link as well.
Also applies to: 44-51
website/src/app/[lang]/[region]/(website)/me/donation-certificates/donation-certificates-table.tsx (1)
33-33
: Add download attribute for better accessibility.The link points to a PDF download, so it should have the
download
attribute.-<Link className={linkCn()} href={data} target="_blank" rel="noopener noreferrer"> +<Link className={linkCn()} href={data} target="_blank" rel="noopener noreferrer" download>website/src/app/[lang]/[region]/(website)/me/subscriptions/subscriptions-client.tsx (1)
92-96
: Consider using Button's href prop instead.Since you're wrapping a Button with a Link, consider using Button's built-in href prop for a cleaner implementation.
-<Link className={linkCn()} href={`/${lang}/${region}/donate/individual`}> - <Button Icon={PlusCircleIcon} variant="ghost" size="lg" className="w-full"> - {translations.newSubscription} - </Button> -</Link> +<Button + href={`/${lang}/${region}/donate/individual`} + Icon={PlusCircleIcon} + variant="ghost" + size="lg" + className="w-full" +> + {translations.newSubscription} +</Button>website/src/app/[lang]/[region]/(website)/campaign/[campaign]/page.tsx (1)
364-373
: Consider adding external arrow indicator.For consistency with other external links in the codebase, consider adding the external arrow indicator.
-className={linkCn({ underline: 'none' })} +className={linkCn({ underline: 'none', arrow: 'external' })}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
website/src/app/[lang]/[region]/(website)/csr/anthony.jpg
is excluded by!**/*.jpg
📒 Files selected for processing (15)
website/src/app/[lang]/[region]/(blue-theme)/donate/individual/page.tsx
(2 hunks)website/src/app/[lang]/[region]/(website)/(home)/(sections)/faq.tsx
(2 hunks)website/src/app/[lang]/[region]/(website)/about-us/(sections)/landing-page.tsx
(3 hunks)website/src/app/[lang]/[region]/(website)/app/page.tsx
(3 hunks)website/src/app/[lang]/[region]/(website)/arts/section-card.tsx
(2 hunks)website/src/app/[lang]/[region]/(website)/books/section-1.tsx
(2 hunks)website/src/app/[lang]/[region]/(website)/campaign/[campaign]/page.tsx
(2 hunks)website/src/app/[lang]/[region]/(website)/csr/page.tsx
(0 hunks)website/src/app/[lang]/[region]/(website)/legal/layout-client.tsx
(0 hunks)website/src/app/[lang]/[region]/(website)/me/contributions/page.tsx
(2 hunks)website/src/app/[lang]/[region]/(website)/me/donation-certificates/donation-certificates-table.tsx
(2 hunks)website/src/app/[lang]/[region]/(website)/me/subscriptions/subscriptions-client.tsx
(2 hunks)website/src/app/[lang]/[region]/(website)/transparency/evidence/section-card.tsx
(2 hunks)website/src/app/not-found.tsx
(1 hunks)website/src/components/faq/faq-section.tsx
(2 hunks)
💤 Files with no reviewable changes (2)
- website/src/app/[lang]/[region]/(website)/legal/layout-client.tsx
- website/src/app/[lang]/[region]/(website)/csr/page.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- website/src/app/[lang]/[region]/(website)/transparency/evidence/section-card.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Test shared code
- GitHub Check: Test admin
- GitHub Check: Test website
- GitHub Check: Test functions
- GitHub Check: Prettify
🔇 Additional comments (4)
website/src/app/not-found.tsx (1)
2-2
: Clean implementation of linkCn with improved layout.The changes properly integrate the linkCn utility while enhancing the layout with better flexbox centering.
Also applies to: 9-9, 16-17
website/src/app/[lang]/[region]/(website)/(home)/(sections)/faq.tsx (1)
7-7
: Well-configured linkCn implementation with proper region handling.The changes demonstrate good use of linkCn options and proper region parameter handling.
Also applies to: 23-30
website/src/components/faq/faq-section.tsx (1)
43-50
: Implementation looks good!The link implementation correctly uses the external arrow variant and proper security attributes.
website/src/app/[lang]/[region]/(website)/about-us/(sections)/landing-page.tsx (1)
41-43
: LGTM!The implementation correctly uses
linkCn
with appropriate configurations and includes security attributes for external links.Also applies to: 69-76, 82-89
Summary by CodeRabbit
Release Notes
New Features
linkCn
with customizable variants.Documentation
Refactor
Style
Bug Fixes