From 0eef74f25fbd6ecef8ce31da73d98509fd256e96 Mon Sep 17 00:00:00 2001 From: thislight Date: Thu, 2 Jan 2025 17:12:48 +0800 Subject: [PATCH] Tabs: fix misplaced indicator --- src/material/Tab.css | 23 +++++++++++++++++++++++ src/material/Tab.tsx | 39 +++------------------------------------ src/material/Tabs.css | 21 +++++++++++++++++++++ src/material/Tabs.tsx | 42 +++++++++++------------------------------- 4 files changed, 58 insertions(+), 67 deletions(-) create mode 100644 src/material/Tab.css create mode 100644 src/material/Tabs.css diff --git a/src/material/Tab.css b/src/material/Tab.css new file mode 100644 index 0000000..83bff90 --- /dev/null +++ b/src/material/Tab.css @@ -0,0 +1,23 @@ +.Tab { + cursor: pointer; + background: none; + border: none; + height: 100%; + max-width: min(calc(100% - 56px), 264px); + padding: 10px 24px; + font-size: 0.8135rem; + font-weight: 600; + text-transform: uppercase; + transition: color 120ms var(--tutu-anim-curve-std); +} + +.MuiToolbar-root .Tab { + color: rgba(255, 255, 255, 0.7); + + &:hover, + &:focus, + &.focus, + &.Tabs-focus { + color: white; + } +} \ No newline at end of file diff --git a/src/material/Tab.tsx b/src/material/Tab.tsx index 2145b89..10d781a 100644 --- a/src/material/Tab.tsx +++ b/src/material/Tab.tsx @@ -1,26 +1,18 @@ import { - Component, createEffect, splitProps, type JSX, type ParentComponent, } from "solid-js"; -import { css } from "solid-styled"; import { useTabListContext } from "./Tabs"; +import "./Tab.css"; const Tab: ParentComponent< { focus?: boolean; - large?: boolean; } & JSX.ButtonHTMLAttributes > = (props) => { - const [managed, rest] = splitProps(props, [ - "focus", - "large", - "type", - "role", - "ref", - ]); + const [managed, rest] = splitProps(props, ["focus", "type", "role", "ref"]); let self: HTMLButtonElement; const { focusOn: [, setFocusOn], @@ -35,32 +27,7 @@ const Tab: ParentComponent< } return managed.focus; }); - css` - .tab { - cursor: pointer; - background: none; - border: none; - min-width: ${managed.large ? "160px" : "72px"}; - height: 48px; - max-width: min(calc(100% - 56px), 264px); - padding: 10px 24px; - font-size: 0.8135rem; - font-weight: 600; - text-transform: uppercase; - transition: color 120ms var(--tutu-anim-curve-std); - } - :global(.MuiToolbar-root) .tab { - color: rgba(255, 255, 255, 0.7); - - &:hover, - &:focus, - &.focus, - &:global(.tablist-focus) { - color: white; - } - } - `; return (