-
Notifications
You must be signed in to change notification settings - Fork 187
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 UI tweaks #1315
Feat UI tweaks #1315
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
import { Button } from '@/components/ui/button'; | ||
|
||
export interface BannerProps { | ||
message: React.ReactNode; | ||
type?: 'info' | 'warning' | 'success' | 'error'; | ||
actionText?: string; | ||
onAction?: () => void; | ||
showBanner?: boolean; | ||
} | ||
|
||
export const Banner: React.FC<BannerProps> = ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stylistic nit: I've been defining components like this: export const Banner = ({foo, bar}: BannerProps) => {} I don't care which we end up going for, but I think we should try to be consistent. WDYT? I kinda like the way I've been doing it because it's a little more terse, but I'm fine either way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. personally prefer React.FC since it adds some additional type safety if needed later There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah nice, vs. just |
||
message, | ||
type = 'info', | ||
actionText, | ||
onAction, | ||
showBanner = true, | ||
}) => { | ||
if (!showBanner) { | ||
return null; | ||
} | ||
grutt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const getBgColor = () => { | ||
switch (type) { | ||
case 'warning': | ||
return 'bg-amber-50 dark:bg-amber-900/20 text-amber-800 dark:text-amber-200'; | ||
case 'success': | ||
return 'bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200'; | ||
case 'error': | ||
return 'bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200'; | ||
default: | ||
return 'bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200'; | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={`w-full py-2 px-4 h-12 ${getBgColor()}`}> | ||
<div className="flex items-center justify-between"> | ||
<div className="flex flex-1 items-center"> | ||
<p className="text-sm font-medium">{message}</p> | ||
</div> | ||
<div className="flex items-center gap-2"> | ||
{actionText && onAction && ( | ||
<Button | ||
variant="outline" | ||
size="sm" | ||
onClick={onAction} | ||
className="text-xs font-medium hover:bg-opacity-20" | ||
> | ||
{actionText} | ||
</Button> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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.
qq: can we make this a 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.
i think we may want to include an icon or additional links here (i.e. link to migration docs)
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.
cool, sounds good