mirror of
https://github.com/zhigang1992/connect.git
synced 2026-03-26 10:14:16 +08:00
fix: minor tweaks and improvements
This commit is contained in:
committed by
Thomas Osmonson
parent
487fa1ba92
commit
309f22f4ca
@@ -15,13 +15,17 @@ const getLineNumber = (n: number, length: number) => startPad(n, length.toString
|
||||
const Tokens = ({
|
||||
tokens,
|
||||
getTokenProps,
|
||||
showLineNumbers,
|
||||
...rest
|
||||
}: {
|
||||
tokens: GrammaticalToken[];
|
||||
getTokenProps: GetGrammaticalTokenProps;
|
||||
showLineNumbers: boolean;
|
||||
}) => {
|
||||
const bsTheme = useTheme();
|
||||
const pl = `calc(${lineNumberWidth}px + ${(bsTheme as any).sizes['base'] || '16px'})`;
|
||||
const pl = `calc(${showLineNumbers ? lineNumberWidth : '0'}px + ${
|
||||
(bsTheme as any).sizes['base'] || '16px'
|
||||
})`;
|
||||
|
||||
return (
|
||||
<Box pl={pl} pr="base" position="relative" zIndex={2} {...rest}>
|
||||
@@ -78,7 +82,7 @@ const Line = ({
|
||||
{...rest}
|
||||
>
|
||||
{showLineNumbers ? <LineNumber number={index} length={length} /> : null}
|
||||
<Tokens getTokenProps={getTokenProps} tokens={tokens} />
|
||||
<Tokens showLineNumbers={showLineNumbers} getTokenProps={getTokenProps} tokens={tokens} />
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -38,6 +38,11 @@ export type TooltipProps = PropsOf<typeof Box> &
|
||||
export function Tooltip(props: TooltipProps) {
|
||||
const { children, label, shouldWrapChildren, 'aria-label': ariaLabel, hasArrow, ...rest } = props;
|
||||
|
||||
if (!label || label === '') {
|
||||
const child = React.Children.only(children) as React.ReactElement;
|
||||
return React.cloneElement(child, { ...child.props, ...rest });
|
||||
}
|
||||
|
||||
const { isOpen, getTriggerProps, getTooltipProps, getArrowProps } = useTooltip(props);
|
||||
|
||||
let trigger: React.ReactElement;
|
||||
|
||||
Reference in New Issue
Block a user