From 44017562775cbffa7441befaeb6a89975a7ad679 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 30 Jun 2023 22:53:17 -0700 Subject: [PATCH] Update PartyHeader and fix behavior * Send true to editable prop is party is editable * Fix turn count token display * Fix party name style * Add custom classes to various Buttons * Only show PartyDropdown if a party is new * Determine which buttons to show based on editable prop, not snapshot * Remove unused code from Header * Make new button route shallowly --- components/Header/index.tsx | 18 +----------------- components/party/Party/index.tsx | 2 +- components/party/PartyHeader/index.module.scss | 14 ++++++++++++++ components/party/PartyHeader/index.tsx | 18 +++++++++--------- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/components/Header/index.tsx b/components/Header/index.tsx index 8e7e8f1c..fccee807 100644 --- a/components/Header/index.tsx +++ b/components/Header/index.tsx @@ -51,22 +51,6 @@ const Header = () => { const [leftMenuOpen, setLeftMenuOpen] = useState(false) const [rightMenuOpen, setRightMenuOpen] = useState(false) - const [name, setName] = useState('') - const [originalName, setOriginalName] = useState('') - - // Snapshots - const { party: partySnapshot } = useSnapshot(appState) - - // Subscribe to app state to listen for party name and - // unsubscribe when component is unmounted - const unsubscribe = subscribe(appState, () => { - const newName = - appState.party && appState.party.name ? appState.party.name : '' - setName(newName) - }) - - useEffect(() => () => unsubscribe(), []) - // Methods: Event handlers (Buttons) function handleLeftMenuButtonClicked() { setLeftMenuOpen(!leftMenuOpen) @@ -126,7 +110,7 @@ const Header = () => { }) // Push the root URL - router.push('/new') + router.push('/new', undefined, { shallow: true }) } const profileImage = () => { diff --git a/components/party/Party/index.tsx b/components/party/Party/index.tsx index 7ef521b7..f7813268 100644 --- a/components/party/Party/index.tsx +++ b/components/party/Party/index.tsx @@ -444,7 +444,7 @@ const Party = (props: Props) => { div { align-items: center; display: inline-flex; font-size: $font-small; height: 26px; + white-space: nowrap; } & > *:not(:last-child):after { @@ -188,6 +193,11 @@ color: var(--text-primary); } + a { + display: flex; + align-items: center; + } + a:hover:not(.fire):not(.water):not(.wind):not(.earth):not(.dark):not( .light ) { @@ -214,6 +224,10 @@ & > .right { display: flex; gap: $unit-half; + + & > * { + flex-grow: 1; + } } } diff --git a/components/party/PartyHeader/index.tsx b/components/party/PartyHeader/index.tsx index f141bbf1..5048f32e 100644 --- a/components/party/PartyHeader/index.tsx +++ b/components/party/PartyHeader/index.tsx @@ -45,9 +45,6 @@ const PartyHeader = (props: Props) => { const router = useRouter() const locale = router.locale || 'en' - const isNewParty = - router.asPath === '/' || router.asPath.split('/')[1] === 'new' - const { party: partySnapshot } = useSnapshot(appState) // State: Component @@ -285,7 +282,7 @@ const PartyHeader = (props: Props) => { {fullAutoToken} {autoSummonToken} {autoGuardToken} - {party.turnCount && turnCountToken} + {party.turnCount !== undefined && turnCountToken} {party.clearTime > 0 && clearTimeToken()} {buttonChainToken()} @@ -300,6 +297,7 @@ const PartyHeader = (props: Props) => { leftAccessoryIcon={} className={classNames({ save: true, + grow: true, saved: partySnapshot.favorited, })} text={ @@ -316,7 +314,7 @@ const PartyHeader = (props: Props) => {