-
Notifications
You must be signed in to change notification settings - Fork 326
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
Fix Drive table #12397
base: develop
Are you sure you want to change the base?
Fix Drive table #12397
Changes from all commits
0d26d21
f8043d0
b5ee64e
951807d
b3dabf4
673b887
dc6ed86
4938880
532930e
c1b7331
5ec659a
65188bf
81209bb
e7c04af
85a9bb9
e3ca1e7
5e59056
7ae9d02
cfd6a5e
c6e79bd
8f50c31
ef51cb2
a95b150
f3f1aa6
438c4f3
2c3b1f2
cab3917
b40c8c9
e68c8b1
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,27 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { IconDisplay, type IconDisplayProps } from './IconDisplay' | ||
|
||
type Props = IconDisplayProps<string> | ||
type Story = StoryObj<Props> | ||
|
||
export default { | ||
title: 'Components/IconDisplay', | ||
component: IconDisplay, | ||
render: (args) => <IconDisplay {...args} />, | ||
tags: ['autodocs'], | ||
args: { icon: 'time', children: 'aaaaaaaa' } satisfies Props, | ||
// `text-primary` is required to make icons show up. | ||
decorators: [(Story, context) => <div className="text-primary">{Story(context)}</div>], | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
} as Meta<Props> | ||
|
||
export const Default: Story = {} | ||
|
||
export const Overflowing: Story = { | ||
args: { | ||
icon: 'sort', | ||
children: 'very long example label that overflows the max width', | ||
} satisfies Props, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** @file A text display with an icon. */ | ||
import { Icon } from '#/components/Icon' | ||
import { tv, type VariantProps } from '#/utilities/tailwindVariants' | ||
import { Text, WithVisualTooltip, type IconProp, type TextProps, type TooltipElementType } from '..' | ||
|
||
const ICON_DISPLAY_STYLES = tv({ | ||
base: 'flex items-center gap-2 max-w-48 min-w-4 px-1', | ||
slots: { | ||
icon: '-mb-0.5', | ||
// For some reason `min-w-0` is required for the ellipsis to appear. | ||
container: 'flex mx-auto min-w-0', | ||
text: 'block truncate', | ||
}, | ||
variants: { | ||
variant: { | ||
custom: '', | ||
link: 'inline-block px-0 py-0 rounded-sm text-primary/50 underline border-0', | ||
primary: 'bg-primary text-white', | ||
accent: 'bg-accent text-white', | ||
ghost: 'text-primary', | ||
submit: 'bg-invite text-white opacity-80', | ||
outline: 'border-0.5 rounded-full border-primary/20 text-primary', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'custom', | ||
}, | ||
}) | ||
|
||
/** Render props for {@link IconDisplay}. */ | ||
export interface IconDisplayRenderProps { | ||
/** Defaults to `true`. */ | ||
readonly isCurrent?: boolean | ||
/** Defaults to `false`. */ | ||
readonly isDisabled?: boolean | ||
} | ||
|
||
/** Props for an {@link IconDisplay}. */ | ||
export interface IconDisplayProps<IconType extends string> | ||
extends Omit<TextProps, 'children' | 'variant' | 'variants'>, | ||
IconDisplayRenderProps, | ||
VariantProps<typeof ICON_DISPLAY_STYLES> { | ||
readonly icon: IconProp<IconType, Required<IconDisplayRenderProps>> | ||
readonly children: | ||
| TooltipElementType | ||
| ((renderProps: Required<IconDisplayRenderProps>) => TooltipElementType) | ||
} | ||
|
||
/** A text display with an icon. */ | ||
export function IconDisplay<IconType extends string>(props: IconDisplayProps<IconType>) { | ||
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. when I told about 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. i guess, but i do want a dedicated component to avoid having to rewrite the markup (and get it right) every time, unless you have a better idea |
||
const { | ||
icon, | ||
isCurrent = true, | ||
isDisabled = false, | ||
children, | ||
variant, | ||
variants = ICON_DISPLAY_STYLES, | ||
tooltip, | ||
...textProps | ||
} = props | ||
const renderProps = { isCurrent, isDisabled } | ||
|
||
const styles = variants({ variant }) | ||
|
||
const renderedChildren = typeof children === 'function' ? children(renderProps) : children | ||
|
||
return ( | ||
<div className={styles.base()}> | ||
<WithVisualTooltip tooltip={tooltip} tooltipPlacement="left"> | ||
<Icon className={styles.icon()} size="medium" renderProps={renderProps}> | ||
{icon} | ||
</Icon> | ||
</WithVisualTooltip> | ||
<div className={styles.container()}> | ||
<Text className={styles.text()} truncate="1" {...textProps} tooltip={renderedChildren}> | ||
{renderedChildren} | ||
</Text> | ||
</div> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** Barrel file for `IconDisplay`. */ | ||
export * from './IconDisplay' |
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.
We used to have a span with
className={styles.text()}
, haven't we?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.
well, i tried extracting the css directly and it doesn't seem to work.
try running this commit in dev (staging env) and create a project execution (no repeats to minimize load, but long timezone to (try to) trigger the
truncate
class):438c4f3