Skip to content

Commit

Permalink
[Tooltip] Component and Hook
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Apr 4, 2024
1 parent b39398a commit a0f5bb5
Show file tree
Hide file tree
Showing 39 changed files with 1,455 additions and 3 deletions.
60 changes: 60 additions & 0 deletions docs/data/base/components/tooltip/UnstyledTooltipDelayGroup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import * as React from 'react';
import { Tooltip, TooltipGroup } from '@mui/base/Tooltip';
import { styled } from '@mui/system';

export default function UnstyledTooltipDelayGroup() {
return (
<div style={{ display: 'flex', gap: 12 }}>
<TooltipGroup closeDelay={200}>
<Tooltip anchorGap={5}>
<Tooltip.AnchorFragment>
<AnchorButton>Anchor A</AnchorButton>
</Tooltip.AnchorFragment>
<TooltipContent>Tooltip A</TooltipContent>
</Tooltip>
<Tooltip anchorGap={5}>
<Tooltip.AnchorFragment>
<AnchorButton>Anchor B</AnchorButton>
</Tooltip.AnchorFragment>
<TooltipContent>Tooltip B</TooltipContent>
</Tooltip>
</TooltipGroup>
</div>
);
}

const blue = {
400: '#3399FF',
600: '#0072E6',
800: '#004C99',
};

export const TooltipContent = styled(Tooltip.Content)`
${({ theme }) => `
background: ${theme.palette.mode === 'dark' ? 'white' : 'black'};
color: ${theme.palette.mode === 'dark' ? 'black' : 'white'};
padding: 4px 6px;
border-radius: 4px;
font-size: 95%;
cursor: default;
`}
`;

export const AnchorButton = styled('button')`
border: none;
background: ${blue[600]};
color: white;
padding: 8px 16px;
border-radius: 4px;
font-size: 16px;
&:focus-visible {
outline: 2px solid ${blue[400]};
outline-offset: 2px;
}
&:hover,
&[data-state='open'] {
background: ${blue[800]};
}
`;
60 changes: 60 additions & 0 deletions docs/data/base/components/tooltip/UnstyledTooltipDelayGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import * as React from 'react';
import { Tooltip, TooltipGroup } from '@mui/base/Tooltip';
import { styled } from '@mui/system';

export default function UnstyledTooltipDelayGroup() {
return (
<div style={{ display: 'flex', gap: 12 }}>
<TooltipGroup closeDelay={200}>
<Tooltip anchorGap={5}>
<Tooltip.AnchorFragment>
<AnchorButton>Anchor A</AnchorButton>
</Tooltip.AnchorFragment>
<TooltipContent>Tooltip A</TooltipContent>
</Tooltip>
<Tooltip anchorGap={5}>
<Tooltip.AnchorFragment>
<AnchorButton>Anchor B</AnchorButton>
</Tooltip.AnchorFragment>
<TooltipContent>Tooltip B</TooltipContent>
</Tooltip>
</TooltipGroup>
</div>
);
}

const blue = {
400: '#3399FF',
600: '#0072E6',
800: '#004C99',
};

export const TooltipContent = styled(Tooltip.Content)`
${({ theme }) => `
background: ${theme.palette.mode === 'dark' ? 'white' : 'black'};
color: ${theme.palette.mode === 'dark' ? 'black' : 'white'};
padding: 4px 6px;
border-radius: 4px;
font-size: 95%;
cursor: default;
`}
`;

export const AnchorButton = styled('button')`
border: none;
background: ${blue[600]};
color: white;
padding: 8px 16px;
border-radius: 4px;
font-size: 16px;
&:focus-visible {
outline: 2px solid ${blue[400]};
outline-offset: 2px;
}
&:hover,
&[data-state='open'] {
background: ${blue[800]};
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<TooltipGroup closeDelay={200}>
<Tooltip anchorGap={5}>
<Tooltip.AnchorFragment>
<AnchorButton>Anchor A</AnchorButton>
</Tooltip.AnchorFragment>
<TooltipContent>Tooltip A</TooltipContent>
</Tooltip>
<Tooltip anchorGap={5}>
<Tooltip.AnchorFragment>
<AnchorButton>Anchor B</AnchorButton>
</Tooltip.AnchorFragment>
<TooltipContent>Tooltip B</TooltipContent>
</Tooltip>
</TooltipGroup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import * as React from 'react';
import { Tooltip } from '@mui/base/Tooltip';
import { styled } from '@mui/system';

export default function UnstyledTooltipIntroduction() {
return (
<Tooltip anchorGap={7}>
<Tooltip.AnchorFragment>
<AnchorButton type="button">Anchor</AnchorButton>
</Tooltip.AnchorFragment>
<TooltipContent>
Tooltip
<TooltipArrow />
</TooltipContent>
</Tooltip>
);
}

const blue = {
400: '#3399FF',
600: '#0072E6',
800: '#004C99',
};

export const TooltipContent = styled(Tooltip.Content)`
${({ theme }) => `
background: ${theme.palette.mode === 'dark' ? 'white' : 'black'};
color: ${theme.palette.mode === 'dark' ? 'black' : 'white'};
padding: 4px 6px;
border-radius: 4px;
font-size: 95%;
cursor: default;
`}
`;

export const AnchorButton = styled('button')`
border: none;
background: ${blue[600]};
color: white;
padding: 8px 16px;
border-radius: 4px;
font-size: 16px;
&:focus-visible {
outline: 2px solid ${blue[400]};
outline-offset: 2px;
}
&:hover,
&[data-state='open'] {
background: ${blue[800]};
}
`;

export const TooltipArrow = styled(Tooltip.Arrow)`
${({ theme }) => `
fill: ${theme.palette.mode === 'dark' ? 'white' : 'black'};
`}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import * as React from 'react';
import { Tooltip } from '@mui/base/Tooltip';
import { styled } from '@mui/system';

export default function UnstyledTooltipIntroduction() {
return (
<Tooltip anchorGap={7}>
<Tooltip.AnchorFragment>
<AnchorButton type="button">Anchor</AnchorButton>
</Tooltip.AnchorFragment>
<TooltipContent>
Tooltip
<TooltipArrow />
</TooltipContent>
</Tooltip>
);
}

const blue = {
400: '#3399FF',
600: '#0072E6',
800: '#004C99',
};

export const TooltipContent = styled(Tooltip.Content)`
${({ theme }) => `
background: ${theme.palette.mode === 'dark' ? 'white' : 'black'};
color: ${theme.palette.mode === 'dark' ? 'black' : 'white'};
padding: 4px 6px;
border-radius: 4px;
font-size: 95%;
cursor: default;
`}
`;

export const AnchorButton = styled('button')`
border: none;
background: ${blue[600]};
color: white;
padding: 8px 16px;
border-radius: 4px;
font-size: 16px;
&:focus-visible {
outline: 2px solid ${blue[400]};
outline-offset: 2px;
}
&:hover,
&[data-state='open'] {
background: ${blue[800]};
}
`;

export const TooltipArrow = styled(Tooltip.Arrow)`
${({ theme }) => `
fill: ${theme.palette.mode === 'dark' ? 'white' : 'black'};
`}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Tooltip anchorGap={7}>
<Tooltip.AnchorFragment>
<AnchorButton type="button">Anchor</AnchorButton>
</Tooltip.AnchorFragment>
<TooltipContent>
Tooltip
<TooltipArrow />
</TooltipContent>
</Tooltip>
Loading

0 comments on commit a0f5bb5

Please sign in to comment.