-
Notifications
You must be signed in to change notification settings - Fork 887
feat(site): show previous agent scripts logs #12233
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
Changes from all commits
707e60e
0d1fb45
5436b15
67bf84b
4258969
93b1184
94a64e9
dbdbedd
29429a7
728af1a
20f25e1
da45599
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 |
---|---|---|
@@ -1,78 +1,95 @@ | ||
import { cx } from "@emotion/css"; | ||
import { type FC, type PropsWithChildren } from "react"; | ||
import { NavLink, NavLinkProps } from "react-router-dom"; | ||
import { Margins } from "components/Margins/Margins"; | ||
import { type ClassName, useClassName } from "hooks/useClassName"; | ||
import { HTMLAttributes, type FC, createContext, useContext } from "react"; | ||
import { Link, LinkProps } from "react-router-dom"; | ||
import { Interpolation, Theme, useTheme } from "@emotion/react"; | ||
|
||
export const TAB_PADDING_Y = 12; | ||
export const TAB_PADDING_X = 16; | ||
|
||
type TabsContextValue = { | ||
active: string; | ||
}; | ||
|
||
const TabsContext = createContext<TabsContextValue | undefined>(undefined); | ||
|
||
type TabsProps = HTMLAttributes<HTMLDivElement> & TabsContextValue; | ||
|
||
export const Tabs: FC<TabsProps> = ({ active, ...htmlProps }) => { | ||
const theme = useTheme(); | ||
|
||
export const Tabs: FC<PropsWithChildren> = ({ children }) => { | ||
return ( | ||
<div | ||
css={(theme) => ({ | ||
borderBottom: `1px solid ${theme.palette.divider}`, | ||
marginBottom: 40, | ||
})} | ||
> | ||
<Margins | ||
<TabsContext.Provider value={{ active }}> | ||
<div | ||
css={{ | ||
display: "flex", | ||
alignItems: "center", | ||
gap: 2, | ||
borderBottom: `1px solid ${theme.palette.divider}`, | ||
}} | ||
> | ||
{children} | ||
</Margins> | ||
</div> | ||
{...htmlProps} | ||
/> | ||
</TabsContext.Provider> | ||
); | ||
}; | ||
|
||
type TabsListProps = HTMLAttributes<HTMLDivElement>; | ||
|
||
export const TabsList: FC<TabsListProps> = (props) => { | ||
return ( | ||
<div | ||
role="tablist" | ||
css={{ | ||
display: "flex", | ||
alignItems: "baseline", | ||
}} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
interface TabLinkProps extends NavLinkProps { | ||
className?: string; | ||
} | ||
type TabLinkProps = LinkProps & { | ||
value: string; | ||
}; | ||
|
||
export const TabLink: FC<TabLinkProps> = ({ | ||
className, | ||
children, | ||
...linkProps | ||
}) => { | ||
const tabLink = useClassName(classNames.tabLink, []); | ||
const activeTabLink = useClassName(classNames.activeTabLink, []); | ||
export const TabLink: FC<TabLinkProps> = ({ value, ...linkProps }) => { | ||
const tabsContext = useContext(TabsContext); | ||
|
||
if (!tabsContext) { | ||
throw new Error("Tab only can be used inside of Tabs"); | ||
} | ||
|
||
const isActive = tabsContext.active === value; | ||
|
||
return ( | ||
<NavLink | ||
className={({ isActive }) => | ||
cx([tabLink, isActive && activeTabLink, className]) | ||
} | ||
<Link | ||
{...linkProps} | ||
> | ||
{children} | ||
</NavLink> | ||
css={[styles.tabLink, isActive ? styles.activeTabLink : ""]} | ||
/> | ||
); | ||
}; | ||
|
||
const classNames = { | ||
tabLink: (css, theme) => css` | ||
text-decoration: none; | ||
color: ${theme.palette.text.secondary}; | ||
font-size: 14px; | ||
display: block; | ||
padding: 0 16px 16px; | ||
|
||
&:hover { | ||
color: ${theme.palette.text.primary}; | ||
} | ||
`, | ||
activeTabLink: (css, theme) => css` | ||
color: ${theme.palette.text.primary}; | ||
position: relative; | ||
|
||
&:before { | ||
content: ""; | ||
left: 0; | ||
bottom: 0; | ||
height: 2px; | ||
width: 100%; | ||
background: ${theme.palette.primary.main}; | ||
position: absolute; | ||
} | ||
`, | ||
} satisfies Record<string, ClassName>; | ||
const styles = { | ||
tabLink: (theme) => ({ | ||
textDecoration: "none", | ||
color: theme.palette.text.secondary, | ||
fontSize: 14, | ||
display: "block", | ||
padding: `${TAB_PADDING_Y}px ${TAB_PADDING_X}px`, | ||
fontWeight: 500, | ||
lineHeight: "1", | ||
|
||
"&:hover": { | ||
color: theme.palette.text.primary, | ||
}, | ||
}), | ||
activeTabLink: (theme) => ({ | ||
color: theme.palette.text.primary, | ||
position: "relative", | ||
|
||
"&:before": { | ||
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. Is this for the accent underline? I'm wondering if it might be more direct to add a bottom border to all the tabs. 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. Yes. In the way you suggested it does not vertically align the content correctly since it is off by 1px at the bottom so you also would need to add a border to the top which starts to make the CSS more "complicated" IMO. I just think the before is easier to understand and implement. |
||
content: '""', | ||
left: 0, | ||
bottom: -1, | ||
height: 1, | ||
width: "100%", | ||
background: theme.palette.primary.main, | ||
position: "absolute", | ||
}, | ||
}), | ||
} satisfies Record<string, Interpolation<Theme>>; |
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.
Big fan of the file changes – looks really clean now.
Once this PR is out, would you be okay with me adding some accessibility code? Mainly want to add some stuff from the APG example for tabs
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.
100% I'm not attached to my code at all 😆