Add Tailwind IntelliSense to objects

This commit is contained in:
Konrad Szwarc 2022-12-08 15:35:16 +01:00
parent 62d771e412
commit c3d75deab8
6 changed files with 21 additions and 12 deletions

View file

@ -6,6 +6,7 @@
"eslint.validate": ["javascript", "javascriptreact", "astro", "typescript", "typescriptreact"], "eslint.validate": ["javascript", "javascriptreact", "astro", "typescript", "typescriptreact"],
"files.eol": "\n", "files.eol": "\n",
"tailwindCSS.classAttributes": ["class", "className", "class:list"], "tailwindCSS.classAttributes": ["class", "className", "class:list"],
"tailwindCSS.experimental.classRegex": [["/\\* tw \\*/ ([^;]*);", "'([^']*)'"]],
"typescript.tsdk": "node_modules/typescript/lib", "typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true, "typescript.enablePromptUseWorkspaceTsdk": true,
"[astro]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[astro]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },

View file

@ -6,7 +6,7 @@ export interface Props {
const { href, download } = Astro.props; const { href, download } = Astro.props;
const classes = { const classes = /* tw */ {
main: 'inline-flex items-center px-4 h-10 text-base font-medium rounded-md shadow-sm text-white bg-primary-600 select-none cursor-pointer', main: 'inline-flex items-center px-4 h-10 text-base font-medium rounded-md shadow-sm text-white bg-primary-600 select-none cursor-pointer',
hover: 'hover:bg-primary-700', hover: 'hover:bg-primary-700',
active: 'active:translate-y-px', active: 'active:translate-y-px',

View file

@ -19,7 +19,7 @@ const sizeMap: Record<IconButtonSize, string> = {
const { icon, href, target, size, ...rest } = Astro.props; const { icon, href, target, size, ...rest } = Astro.props;
const classes = { const classes = /* tw */ {
main: 'flex items-center justify-center rounded text-gray-400 bg-gray-100 dark:bg-gray-600 dark:text-gray-200', main: 'flex items-center justify-center rounded text-gray-400 bg-gray-100 dark:bg-gray-600 dark:text-gray-200',
active: 'active:translate-y-px', active: 'active:translate-y-px',
focus: 'focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500', focus: 'focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500',

View file

@ -14,6 +14,12 @@ export interface SidebarItemProps {
export const MAIN_SECTION: Section = 'main'; export const MAIN_SECTION: Section = 'main';
const classes = /* tw */ {
main: 'inline-flex h-10 w-10 items-center justify-center rounded-lg transition',
active: 'bg-primary-600 text-white',
inactive: 'bg-white text-gray-400 hover:bg-primary-600 hover:text-white dark:bg-gray-800 dark:text-gray-200',
};
const SidebarItem = ({ section, icon, title = '' }: SidebarItemProps) => { const SidebarItem = ({ section, icon, title = '' }: SidebarItemProps) => {
const { hash } = useLocation(); const { hash } = useLocation();
const href = `#${section}`; const href = `#${section}`;
@ -24,13 +30,7 @@ const SidebarItem = ({ section, icon, title = '' }: SidebarItemProps) => {
<Tooltip content={`${title || section.charAt(0).toUpperCase() + section.slice(1)} section`} placement="left"> <Tooltip content={`${title || section.charAt(0).toUpperCase() + section.slice(1)} section`} placement="left">
<a <a
href={href} href={href}
className={`inline-flex h-10 w-10 items-center justify-center rounded-lg transition className={`${classes.main} ${active ? classes.active : classes.inactive}`}
${
active
? 'bg-primary-600 text-white'
: 'bg-white text-gray-400 hover:bg-primary-600 hover:text-white dark:bg-gray-800 dark:text-gray-200'
}
`}
aria-current={active ? 'page' : undefined} aria-current={active ? 'page' : undefined}
aria-label={`${section} section`} aria-label={`${section} section`}
> >

View file

@ -7,8 +7,16 @@ export interface Props {
const { skillLevel, tileLevel } = Astro.props; const { skillLevel, tileLevel } = Astro.props;
const isFilled = skillLevel >= tileLevel; const isFilled = skillLevel >= tileLevel;
const filledClass = isFilled ? 'bg-gray-500 dark:bg-gray-300' : 'bg-gray-200 dark:bg-gray-500'; const classes = /* tw */ {
filled: 'bg-gray-500 dark:bg-gray-300',
empty: 'bg-gray-200 dark:bg-gray-500',
};
--- ---
<div class={`w-9 h-2 last:rounded-l-none last:rounded-r-sm first:rounded-l-sm first:rounded-r-none ${filledClass}`}> <div
class:list={[
'w-9 h-2 last:rounded-l-none last:rounded-r-sm first:rounded-l-sm first:rounded-r-none',
isFilled ? classes.filled : classes.empty,
]}
>
</div> </div>

View file

@ -74,7 +74,7 @@ const section: Section = 'favorites';
<Typography variant="section-subtitle" id={`${section}-${name}-heading`}> <Typography variant="section-subtitle" id={`${section}-${name}-heading`}>
{subsectionTitle} {subsectionTitle}
</Typography> </Typography>
<div class={`grid gap-8 ${columnsLayout}`}> <div class:list={['grid gap-8', columnsLayout]}>
{data.map((value) => ( {data.map((value) => (
<Component value={value} /> <Component value={value} />
))} ))}