use styled-jsx in HeaderBar
This commit is contained in:
parent
0b308e570e
commit
57bf32cad9
@ -9,8 +9,8 @@ import "@szhsin/react-menu/dist/index.css";
|
|||||||
import "@szhsin/react-menu/dist/transitions/slide.css";
|
import "@szhsin/react-menu/dist/transitions/slide.css";
|
||||||
|
|
||||||
function renderNewGameButton(
|
function renderNewGameButton(
|
||||||
context: Context, game:
|
context: Context,
|
||||||
MancalaGame | undefined,
|
game: MancalaGame | undefined,
|
||||||
onNewGameClick: () => void,
|
onNewGameClick: () => void,
|
||||||
userKeyWhoLeave: string | undefined,
|
userKeyWhoLeave: string | undefined,
|
||||||
crashMessage: string | undefined): JSX.Element {
|
crashMessage: string | undefined): JSX.Element {
|
||||||
@ -51,31 +51,12 @@ const HeaderBar: FunctionComponent<{
|
|||||||
context.themeManager.theme.textLightColor
|
context.themeManager.theme.textLightColor
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{ background: context.themeManager.theme.appBarBgColor }} className="header-bar">
|
||||||
padding: "0px 4vw",
|
<h1 style={{ color: textColor }} className="header-bar-title">
|
||||||
background: context.themeManager.theme.appBarBgColor,
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
alignSelf: "stretch",
|
|
||||||
}}>
|
|
||||||
<h1 style={{ color: textColor, margin: "10px 0px" }}>
|
|
||||||
{context.texts.Mancala}
|
{context.texts.Mancala}
|
||||||
</h1>
|
</h1>
|
||||||
<div style={{
|
<div className="header-bar-right-panel">
|
||||||
display: "flex",
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
}} >
|
|
||||||
<div style={{
|
|
||||||
marginRight: "1vw",
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
}}>
|
|
||||||
<ThemeSwitchMenu context={context} textColor={textColor} />
|
<ThemeSwitchMenu context={context} textColor={textColor} />
|
||||||
</div>
|
|
||||||
{renderNewGameButton(context, game, onNewGameClick, userKeyWhoLeave, crashMessage)}
|
{renderNewGameButton(context, game, onNewGameClick, userKeyWhoLeave, crashMessage)}
|
||||||
{game &&
|
{game &&
|
||||||
!userKeyWhoLeave &&
|
!userKeyWhoLeave &&
|
||||||
@ -88,6 +69,25 @@ const HeaderBar: FunctionComponent<{
|
|||||||
onClick={onLeaveGameClick} />
|
onClick={onLeaveGameClick} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<style jsx>{`
|
||||||
|
.header-bar {
|
||||||
|
padding: 0px 4vw;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-self: stretch;
|
||||||
|
}
|
||||||
|
.header-bar-title {
|
||||||
|
margin: 10px 0px;
|
||||||
|
}
|
||||||
|
.header-bar-right-panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
</div>)
|
</div>)
|
||||||
}
|
}
|
||||||
export default HeaderBar;
|
export default HeaderBar;
|
||||||
@ -100,33 +100,46 @@ const ThemeSwitchMenu: FunctionComponent<{ context: Context, textColor: string }
|
|||||||
light_mode
|
light_mode
|
||||||
</span>;
|
</span>;
|
||||||
const menuItems = context.themeManager.themes.map((theme, index) => {
|
const menuItems = context.themeManager.themes.map((theme, index) => {
|
||||||
return (<MenuItem
|
const themeBackground = context.themeManager.theme.background;
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
key={index}
|
key={index}
|
||||||
style={{ color: textColor }}
|
style={{ color: textColor }}
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
onMouseOver={(event) => (event.target.style.background =
|
onMouseOver={(event) => (event.target.style.background = themeBackground)}
|
||||||
context.themeManager.theme.background)}
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
onMouseOut={(event) => (event.target.style.background = "transparent")}
|
onMouseOut={(event) => (event.target.style.background = "transparent")}
|
||||||
onClick={() => (context.themeManager.theme = theme)}>
|
onClick={() => (context.themeManager.theme = theme)}>
|
||||||
<div style={{
|
<div style={{ background: theme.boardColor }} className="theme-color-circle" />
|
||||||
borderRadius: "5vw",
|
|
||||||
background: theme.boardColor,
|
|
||||||
width: "1vw",
|
|
||||||
height: "1vw",
|
|
||||||
marginRight: "1vw",
|
|
||||||
}} />
|
|
||||||
{theme.name}
|
{theme.name}
|
||||||
</MenuItem>);
|
<style jsx>{`
|
||||||
|
.theme-color-circle {
|
||||||
|
border-radius: 5vw;
|
||||||
|
width: 1vw;
|
||||||
|
height: 1vw;
|
||||||
|
margin-right: 1vw;
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
})
|
})
|
||||||
return (<Menu
|
return (
|
||||||
menuStyle={{
|
<div className="menu-container">
|
||||||
background: context.themeManager.theme.appBarBgColor,
|
<Menu
|
||||||
}}
|
menuStyle={{ background: context.themeManager.theme.appBarBgColor }}
|
||||||
menuButton={menuButton}
|
menuButton={menuButton}
|
||||||
transition
|
transition
|
||||||
align="end">
|
align="end">
|
||||||
{menuItems}
|
{menuItems}
|
||||||
</Menu>);
|
</Menu>
|
||||||
|
<style jsx>{`
|
||||||
|
.menu-container {
|
||||||
|
margin: 0 1vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user