Skip to content

Commit

Permalink
Merge pull request #909 from openameba/feature/add-navigation-tab
Browse files Browse the repository at this point in the history
feat(spindle-ui): add `NavigationTab/UnderlineTab` component
  • Loading branch information
itsminadesu authored Feb 6, 2024
2 parents 9d9523d + 676707e commit 463c65b
Show file tree
Hide file tree
Showing 8 changed files with 886 additions and 33 deletions.
213 changes: 213 additions & 0 deletions packages/spindle-ui/src/NavigationTab/UnderlineTab/UnderlineTab.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
.spui-UnderlineTab {
background-color: var(--color-surface-primary);
}

.spui-UnderlineTab--border {
border-bottom: 1px solid var(--color-border-low-emphasis);
}

.spui-UnderlineTab--scrollable {
position: relative;
}

.spui-UnderlineTab-container {
align-items: center;
display: flex;
}

.spui-UnderlineTab--scrollable .spui-UnderlineTab-container {
column-gap: 16px;
overflow-x: scroll;
padding: 0 16px;
scroll-behavior: smooth;
}

.spui-UnderlineTab-button {
background-color: transparent;
border: none;
box-sizing: border-box;
flex-shrink: 0;
padding: 0 4px;
transition: background-color 0.15s ease-in-out;
}

.spui-UnderlineTab--fixed .spui-UnderlineTab-button {
width: 100%;
}

.spui-UnderlineTab--scrollable .spui-UnderlineTab-button {
min-width: 44px;
}

.spui-UnderlineTab-button:hover {
background-color: var(--color-surface-tertiary);
}

.spui-UnderlineTab-button:focus {
border-radius: 4px;
outline: 2px solid var(--color-focus-clarity);
outline-offset: -2px;
}

.spui-UnderlineTab-button:not(:focus-visible) {
outline: none;
}

.spui-UnderlineTab-labelWrapper {
align-items: center;
column-gap: 6px;
display: flex;
margin: 0 auto;
max-width: 100%;
padding: 14px 0;
position: relative;
width: fit-content;
}

.spui-UnderlineTab-labelWrapper::after {
background-color: var(--color-border-accent-primary);
border-radius: 3px;
bottom: 0;
content: '';
height: 3px;
left: 50%;
min-width: 40px;
opacity: 0;
position: absolute;
transform: translateX(-50%);
transition: opacity 0.35s ease-in-out;
width: 100%;
}

/* stylelint-disable-next-line */
.spui-UnderlineTab-button[aria-selected='true'] .spui-UnderlineTab-labelWrapper::after {
opacity: 1;
}

.spui-UnderlineTab-label {
color: var(--color-text-low-emphasis);
font-size: 0.875rem;
font-weight: bold;
line-height: 1.3;
}

.spui-UnderlineTab--fixed .spui-UnderlineTab-label {
min-width: 0;
overflow-wrap: break-word;
}

/* stylelint-disable-next-line */
.spui-UnderlineTab-button[aria-selected='true'] .spui-UnderlineTab-label {
color: var(--color-text-accent-primary);
}

.spui-UnderlineTab-badge {
background-color: var(--color-surface-accent-primary);
border-radius: 8px;
box-sizing: border-box;
color: var(--color-text-high-emphasis-inverse);
flex-shrink: 0;
font-size: 0.6875rem;
font-weight: bold;
line-height: 1.3;
min-width: 20px;
padding: 1px 4px;
}

.spui-UnderlineTab-visuallyHidden {
clip: rect(1px, 1px, 1px, 1px);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
width: 1px;
}

.spui-UnderlineTab-arrow {
background-color: var(--color-surface-primary);
bottom: 0;
height: fit-content;
margin: auto;
opacity: 0;
position: absolute;
top: 0;
transition:
opacity 0.35s ease-in-out,
visibility 0.35s ease-in-out;
visibility: hidden;
z-index: 1;
}

.spui-UnderlineTab-arrow.is-showed {
opacity: 1;
visibility: visible;
}

.spui-UnderlineTab-arrow::before {
content: '';
height: 100%;
position: absolute;
width: 10px;
z-index: -1;
}

.spui-UnderlineTab-arrow--left {
left: 0;
}

.spui-UnderlineTab-arrow--left::before {
background: linear-gradient(
270deg,
rgba(255, 255, 255, 0) 0,
var(--color-surface-primary) 100%
);
left: 44px; /* ボタンの横幅分 */
}

.spui-UnderlineTab-arrow--right {
right: 0;
}

.spui-UnderlineTab-arrow--right::before {
background: linear-gradient(
270deg,
var(--color-surface-primary) 0,
rgba(255, 255, 255, 0) 100%
);
right: 44px; /* ボタンの横幅分 */
}

.spui-UnderlineTab-arrowButton {
background-color: transparent;
border: none;
border-radius: 8px;
color: var(--color-object-low-emphasis);
display: flex;
padding: 14px;
transition: background-color 0.15s ease-in-out;
}

.spui-UnderlineTab-arrowButton:hover {
background-color: var(--color-surface-tertiary);
}

.spui-UnderlineTab-arrowButton:focus {
outline: 2px solid var(--color-focus-clarity);
}

.spui-UnderlineTab-arrowButton:not(:focus-visible) {
outline: none;
}

@media (prefers-reduced-motion: reduce) {
.spui-UnderlineTab-button,
.spui-UnderlineTab-labelWrapper::after,
.spui-UnderlineTab-arrow,
.spui-UnderlineTab-arrowButton {
transition: 0.1ms;
}

.spui-UnderlineTab--scrollable .spui-UnderlineTab-container {
scroll-behavior: auto;
}
}
Loading

0 comments on commit 463c65b

Please sign in to comment.