Skip to content

Commit

Permalink
Merge pull request #30 from pishposh/mg-refactor-header
Browse files Browse the repository at this point in the history
Refactor header
  • Loading branch information
mattgrunwald authored Nov 7, 2024
2 parents 03aea81 + 550d869 commit d27bf9c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 23 deletions.
23 changes: 10 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { InfoDialog } from './components/InfoDialog';
import { PicketSign } from './components/PicketSign';
import { ResultsDialog } from './components/ResultsDialog';
import { Scoreboard } from './components/Scoreboard';
import { TextOrIcon } from './components/TextOrIcon';
import { Game, NewGame } from './game';

function App() {
Expand Down Expand Up @@ -54,20 +55,16 @@ function App() {
return (
<>
<Header>
<a href="https://nytimesguild.org/tech/guild-builds/">More Games</a>
<a href="https://nytimesguild.org/tech/guild-builds/">
<TextOrIcon icon="👾" text="More Games" />
</a>

<span
className="link-alike"
onClick={() => setInfoDialogOpen(!infoDialogOpen)}
>
What’s this?
</span>
<span
className="link-alike"
onClick={() => setGameSettingsOpen(!gameSettingsOpen)}
>
Settings
</span>
<button onClick={() => setInfoDialogOpen(!infoDialogOpen)}>
<TextOrIcon icon="❓" text="What's this?" />
</button>
<button onClick={() => setGameSettingsOpen(!gameSettingsOpen)}>
<TextOrIcon icon="⚙️" text="Settings" />
</button>
{gameSettingsOpen && (
<GameSettings
onClose={() => setGameSettingsOpen(false)}
Expand Down
21 changes: 15 additions & 6 deletions src/components/Header/Header.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,37 @@
}

#header a {
text-decoration: underline;
&:has(.toi-icon) {
text-decoration: unset;
}
.toi-text {
text-decoration: underline;
}
}

.header-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
display: flex;
justify-content: space-between;

> div {
width: 100%;
width: 33%;
display: flex;
align-items: center;
}

> div.header-title {
justify-content: center;
font-size: x-large;
min-width: 145px;
}

> div.header-links {
justify-content: end;
& > a, & > .link-alike {
margin-left: 1rem;

button {
margin-left: 0.5rem;
padding: 0.25rem;
background-color: inherit;
}
}
}
6 changes: 2 additions & 4 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import './Header.css';
export const Header = ({ children }: PropsWithChildren) => (
<header id="header">
<div className="header-container">
<div />
<div className="header-spacer" />
<div className="header-title">
<b>Match Strike</b>
</div>
<div className="header-links">
{children}
</div>
<div className="header-links">{children}</div>
</div>
</header>
);
14 changes: 14 additions & 0 deletions src/components/TextOrIcon/TextOrIcon.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@media (min-width: 910px) {
.toi-icon {
display: none;
}
}

@media (max-width: 910px) {
.toi-icon {
font-size: x-large;
}
.toi-text {
display: none;
}
}
12 changes: 12 additions & 0 deletions src/components/TextOrIcon/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import './TextOrIcon.css';

export const TextOrIcon = ({ text, icon }: { text: string; icon: string }) => (
<>
<span className="toi-text" aria-label={text}>
{text}
</span>
<span className="toi-icon" aria-label={text}>
{icon}
</span>
</>
);

0 comments on commit d27bf9c

Please sign in to comment.