mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-18 15:44:36 +00:00
tabs styling
This commit is contained in:
1 parent
d71637598d
commit
90ebabafcd
3 files changed
+58
-9
No files matched your search
@@ -0,0 +1,25 @@
|
||||
@import "scss/colours.scss";
|
||||
|
||||
.nav-tabs {
|
||||
border-bottom: 2px solid #ffffff15;
|
||||
|
||||
.nav-link {
|
||||
border: none;
|
||||
padding: 1rem 1.4rem;
|
||||
border-bottom: 4px solid transparent;
|
||||
color: rgba($white, 0.5);
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
transition: 0.2s;
|
||||
|
||||
&:hover {
|
||||
color: rgba($white, 0.75);
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: $white;
|
||||
background-color: transparent;
|
||||
border-bottom: 4px solid $primary;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import React, { useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { NavLink } from "react-router-dom";
|
||||
import { useSpring, a } from "@react-spring/web";
|
||||
import "./Tabs.scss";
|
||||
|
||||
interface TabProps {
|
||||
to: string;
|
||||
@@ -15,13 +17,14 @@ interface TabContentProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
function Tab({ to, label }: TabProps) {
|
||||
function Tab({ to, label, onClick }: TabProps & { onClick: () => void }) {
|
||||
return (
|
||||
<li className="nav-item">
|
||||
<NavLink
|
||||
to={to}
|
||||
className="nav-link fs-6 px-3 px-lg-4"
|
||||
activeClassName="active"
|
||||
onClick={onClick}
|
||||
>
|
||||
{label}
|
||||
</NavLink>
|
||||
@@ -36,23 +39,44 @@ function TabContent({ children }: TabContentProps) {
|
||||
function Tabs({ tabs }: TabsProps) {
|
||||
const [activeTab, setActiveTab] = useState(tabs[0].to);
|
||||
|
||||
const [fade, setFade] = useSpring(() => ({
|
||||
opacity: 1,
|
||||
from: { opacity: 0 },
|
||||
config: { duration: 50 },
|
||||
}));
|
||||
|
||||
useEffect(() => {
|
||||
setFade({ opacity: 1 });
|
||||
}, [activeTab, setFade]);
|
||||
|
||||
const handleTabClick = (tabTo: string) => {
|
||||
setFade({ opacity: 0 });
|
||||
setTimeout(() => setActiveTab(tabTo), 50);
|
||||
};
|
||||
|
||||
return (
|
||||
<nav>
|
||||
<ul className="nav nav-tabs">
|
||||
{tabs.map((tab) => (
|
||||
<Tab key={tab.to} to={tab.to} label={tab.label} />
|
||||
<Tab
|
||||
key={tab.to}
|
||||
to={tab.to}
|
||||
label={tab.label}
|
||||
onClick={() => handleTabClick(tab.to)}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
<TabContent>
|
||||
{tabs.map((tab) => (
|
||||
<div
|
||||
<a.div
|
||||
key={tab.to}
|
||||
style={fade}
|
||||
className={`tab-pane fade ${
|
||||
activeTab === tab.to ? "show active" : ""
|
||||
}`}
|
||||
>
|
||||
{tab.content}
|
||||
</div>
|
||||
</a.div>
|
||||
))}
|
||||
</TabContent>
|
||||
</nav>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable jsx-a11y/anchor-is-valid */
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import { Gravatar } from "@storyteller/components/src/elements/Gravatar";
|
||||
import { Link, NavLink, Redirect, useLocation } from "react-router-dom";
|
||||
import { Link, Redirect, useLocation } from "react-router-dom";
|
||||
import { SessionWrapper } from "@storyteller/components/src/session/SessionWrapper";
|
||||
import { SessionSubscriptionsWrapper } from "@storyteller/components/src/session/SessionSubscriptionsWrapper";
|
||||
import { useParams } from "react-router-dom";
|
||||
@@ -153,7 +153,7 @@ function NewProfilePage(this: any, props: Props) {
|
||||
|
||||
// Mods shouldn't edit preferences.
|
||||
const buttonLabel = props.sessionWrapper.userTokenMatches(
|
||||
userData.user_token
|
||||
userData.user_token,
|
||||
)
|
||||
? "Edit Profile & Preferences"
|
||||
: "Edit Profile";
|
||||
@@ -207,7 +207,7 @@ function NewProfilePage(this: any, props: Props) {
|
||||
>
|
||||
<FontAwesomeIcon icon={faCalendarAlt} className="me-2" />
|
||||
<p className="fw-normal">Joined {joinDate}</p>
|
||||
</div>
|
||||
</div>,
|
||||
);
|
||||
|
||||
if (userData.website_url !== undefined && userData.website_url !== null) {
|
||||
@@ -299,7 +299,7 @@ function NewProfilePage(this: any, props: Props) {
|
||||
>
|
||||
<FontAwesomeIcon icon={faDiscord} />
|
||||
</a>
|
||||
</Tippy>
|
||||
</Tippy>,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user