mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
refactor(console): tab nav (#2471)
This commit is contained in:
parent
e56238e6b6
commit
27e236fda2
10 changed files with 76 additions and 26 deletions
|
@ -1,27 +1,61 @@
|
||||||
@use '@/scss/underscore' as _;
|
@use '@/scss/underscore' as _;
|
||||||
|
|
||||||
.link {
|
.item {
|
||||||
font: var(--font-subhead-2);
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
&:not(:last-child) {
|
&:not(:last-child) {
|
||||||
margin-right: _.unit(6);
|
margin-right: _.unit(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
font: var(--font-subhead-2);
|
||||||
|
padding: _.unit(0.5) _.unit(1.5);
|
||||||
|
margin-bottom: _.unit(1);
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
color: var(--color-text-secondary);
|
color: var(--color-text-secondary);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding-bottom: _.unit(1);
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--color-hover-variant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.selected {
|
.selected {
|
||||||
|
position: relative;
|
||||||
color: var(--color-text-link);
|
color: var(--color-text-link);
|
||||||
border-bottom: 2px solid var(--color-text-link);
|
|
||||||
margin-bottom: -1px;
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: var(--color-text-link);
|
color: var(--color-text-link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
// Note: link item's margin-bottom (_.unit(1)) + TabNav's border-bottom width (1px)
|
||||||
|
bottom: -5px;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
border-top: 2px solid var(--color-text-link);
|
||||||
|
border-radius: 8px 8px 0 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.errors {
|
||||||
|
margin-left: _.unit(0.5);
|
||||||
|
font: var(--font-label-medium);
|
||||||
|
color: var(--color-white);
|
||||||
|
padding: _.unit(0.5) _.unit(1.5);
|
||||||
|
background-color: var(--color-error-50);
|
||||||
|
border-radius: 10px;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-bottom: _.unit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Link, useLocation } from 'react-router-dom';
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
import { onKeyDownHandler } from '@/utilities/a11y';
|
import { onKeyDownHandler } from '@/utilities/a11y';
|
||||||
|
@ -8,15 +9,18 @@ import * as styles from './TabNavItem.module.scss';
|
||||||
type Props = {
|
type Props = {
|
||||||
href?: string;
|
href?: string;
|
||||||
isActive?: boolean;
|
isActive?: boolean;
|
||||||
|
errorCount?: number;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TabNavItem = ({ children, href, isActive, onClick }: Props) => {
|
const TabNavItem = ({ children, href, isActive, errorCount = 0, onClick }: Props) => {
|
||||||
|
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const selected = href ? location.pathname === href : isActive;
|
const selected = href ? location.pathname === href : isActive;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<div className={styles.item}>
|
||||||
<div className={classNames(styles.link, selected && styles.selected)}>
|
<div className={classNames(styles.link, selected && styles.selected)}>
|
||||||
{href ? (
|
{href ? (
|
||||||
<Link to={href}>{children}</Link>
|
<Link to={href}>{children}</Link>
|
||||||
|
@ -27,6 +31,10 @@ const TabNavItem = ({ children, href, isActive, onClick }: Props) => {
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{errorCount > 0 && (
|
||||||
|
<div className={styles.errors}>{t('general.tab_errors', { count: errorCount })}</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav {
|
.nav {
|
||||||
padding: 0 _.unit(6);
|
padding: 0 _.unit(6) 1px;
|
||||||
margin: _.unit(6) 0 0 0;
|
margin-top: _.unit(6);
|
||||||
|
border-bottom: unset;
|
||||||
}
|
}
|
||||||
|
|
||||||
.body {
|
.body {
|
||||||
|
|
|
@ -41,6 +41,7 @@ const general = {
|
||||||
got_it: 'Got it', // UNTRANSLATED
|
got_it: 'Got it', // UNTRANSLATED
|
||||||
page_info: '{{min, number}}-{{max, number}} of {{total, number}}', // UNTRANSLATED
|
page_info: '{{min, number}}-{{max, number}} of {{total, number}}', // UNTRANSLATED
|
||||||
learn_more: 'Learn more', // UNTRANSLATED
|
learn_more: 'Learn more', // UNTRANSLATED
|
||||||
|
tab_errors: '{{count, number}} errors', // UNTRANSLATED
|
||||||
};
|
};
|
||||||
|
|
||||||
export default general;
|
export default general;
|
||||||
|
|
|
@ -40,6 +40,7 @@ const general = {
|
||||||
got_it: 'Got it',
|
got_it: 'Got it',
|
||||||
page_info: '{{min, number}}-{{max, number}} of {{total, number}}',
|
page_info: '{{min, number}}-{{max, number}} of {{total, number}}',
|
||||||
learn_more: 'Learn more',
|
learn_more: 'Learn more',
|
||||||
|
tab_errors: '{{count, number}} errors',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default general;
|
export default general;
|
||||||
|
|
|
@ -41,6 +41,7 @@ const general = {
|
||||||
got_it: 'Got it', // UNTRANSLATED
|
got_it: 'Got it', // UNTRANSLATED
|
||||||
page_info: '{{min, number}}-{{max, number}} of {{total, number}}', // UNTRANSLATED
|
page_info: '{{min, number}}-{{max, number}} of {{total, number}}', // UNTRANSLATED
|
||||||
learn_more: 'Learn more', // UNTRANSLATED
|
learn_more: 'Learn more', // UNTRANSLATED
|
||||||
|
tab_errors: '{{count, number}} errors', // UNTRANSLATED
|
||||||
};
|
};
|
||||||
|
|
||||||
export default general;
|
export default general;
|
||||||
|
|
|
@ -40,6 +40,7 @@ const general = {
|
||||||
got_it: 'Got it', // UNTRANSLATED
|
got_it: 'Got it', // UNTRANSLATED
|
||||||
page_info: '{{min, number}}-{{max, number}} of {{total, number}}', // UNTRANSLATED
|
page_info: '{{min, number}}-{{max, number}} of {{total, number}}', // UNTRANSLATED
|
||||||
learn_more: 'Learn more', // UNTRANSLATED
|
learn_more: 'Learn more', // UNTRANSLATED
|
||||||
|
tab_errors: '{{count, number}} errors', // UNTRANSLATED
|
||||||
};
|
};
|
||||||
|
|
||||||
export default general;
|
export default general;
|
||||||
|
|
|
@ -40,6 +40,7 @@ const general = {
|
||||||
got_it: 'Got it', // UNTRANSLATED
|
got_it: 'Got it', // UNTRANSLATED
|
||||||
page_info: '{{min, number}}-{{max, number}} of {{total, number}}', // UNTRANSLATED
|
page_info: '{{min, number}}-{{max, number}} of {{total, number}}', // UNTRANSLATED
|
||||||
learn_more: 'Learn more', // UNTRANSLATED
|
learn_more: 'Learn more', // UNTRANSLATED
|
||||||
|
tab_errors: '{{count, number}} errors', // UNTRANSLATED
|
||||||
};
|
};
|
||||||
|
|
||||||
export default general;
|
export default general;
|
||||||
|
|
|
@ -41,6 +41,7 @@ const general = {
|
||||||
got_it: 'Got it', // UNTRANSLATED
|
got_it: 'Got it', // UNTRANSLATED
|
||||||
page_info: '{{min, number}}-{{max, number}} of {{total, number}}', // UNTRANSLATED
|
page_info: '{{min, number}}-{{max, number}} of {{total, number}}', // UNTRANSLATED
|
||||||
learn_more: 'Learn more', // UNTRANSLATED
|
learn_more: 'Learn more', // UNTRANSLATED
|
||||||
|
tab_errors: '{{count, number}} errors', // UNTRANSLATED
|
||||||
};
|
};
|
||||||
|
|
||||||
export default general;
|
export default general;
|
||||||
|
|
|
@ -40,6 +40,7 @@ const general = {
|
||||||
got_it: 'Got it', // UNTRANSLATED
|
got_it: 'Got it', // UNTRANSLATED
|
||||||
page_info: '{{min, number}}-{{max, number}} 共 {{total, number}} 条', // UNTRANSLATED
|
page_info: '{{min, number}}-{{max, number}} 共 {{total, number}} 条', // UNTRANSLATED
|
||||||
learn_more: 'Learn more', // UNTRANSLATED
|
learn_more: 'Learn more', // UNTRANSLATED
|
||||||
|
tab_errors: '{{count, number}} errors', // UNTRANSLATED
|
||||||
};
|
};
|
||||||
|
|
||||||
export default general;
|
export default general;
|
||||||
|
|
Loading…
Add table
Reference in a new issue