Fix segmented control styles

This commit is contained in:
Justin Edmund 2023-06-23 19:14:34 -07:00
parent 6051a814fa
commit 558a4e74a1
12 changed files with 200 additions and 205 deletions

View file

@ -1,13 +1,12 @@
.SegmentedControlWrapper { .wrapper {
display: flex; display: flex;
justify-content: center; justify-content: center;
@include breakpoint(phone) { @include breakpoint(phone) {
width: 100%; width: 100%;
} }
}
.SegmentedControl { .segmentedControl {
// border-radius: $unit * 3; // border-radius: $unit * 3;
display: inline-flex; display: inline-flex;
padding: 3px; padding: 3px;
@ -21,7 +20,7 @@
border-radius: 100px; border-radius: 100px;
} }
&.Blended { &.blended {
background: var(--input-bound-bg); background: var(--input-bound-bg);
border-radius: $full-corner; border-radius: $full-corner;
@ -30,6 +29,14 @@
} }
} }
&.grow {
flex-grow: 1;
}
&.gap {
gap: $unit;
}
&.fire { &.fire {
.Segment input:checked + label { .Segment input:checked + label {
background: var(--fire-bg); background: var(--fire-bg);
@ -102,3 +109,4 @@
} }
} }
} }
}

View file

@ -6,6 +6,8 @@ interface Props {
className?: string className?: string
elementClass?: string elementClass?: string
blended?: boolean blended?: boolean
grow?: boolean
gap?: boolean
tabIndex?: number tabIndex?: number
} }
@ -13,19 +15,23 @@ const SegmentedControl: React.FC<Props> = ({
className, className,
elementClass, elementClass,
blended, blended,
grow,
gap,
tabIndex, tabIndex,
children, children,
}) => { }) => {
const classes = classNames( const classes = classNames(
{ {
SegmentedControl: true, [styles.segmentedControl]: true,
Blended: blended, [styles.blended]: blended,
[styles.grow]: grow,
[styles.gap]: gap,
}, },
className, className,
elementClass elementClass
) )
return ( return (
<div className="SegmentedControlWrapper" tabIndex={tabIndex}> <div className={styles.wrapper} tabIndex={tabIndex}>
<div className={classes}>{children}</div> <div className={classes}>{children}</div>
</div> </div>
) )
@ -33,6 +39,8 @@ const SegmentedControl: React.FC<Props> = ({
SegmentedControl.defaultProps = { SegmentedControl.defaultProps = {
blended: false, blended: false,
grow: false,
gap: false,
} }
export default SegmentedControl export default SegmentedControl

View file

@ -1,4 +1,4 @@
.PartyNavigation { .nav {
align-items: center; align-items: center;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
@ -43,27 +43,3 @@
} }
} }
} }
.ExtraSwitch {
color: #888;
display: flex;
font-weight: $normal;
gap: $unit;
line-height: 34px;
height: 100%;
position: absolute;
right: 0px;
top: 1px;
// prettier-ignore
@media only screen
and (max-width: 550px)
and (max-height: 920px)
and (-webkit-min-device-pixel-ratio: 2) {
position: static;
.Text {
display: none;
}
}
}

View file

@ -106,18 +106,17 @@ const PartySegmentedControl = (props: Props) => {
} }
return ( return (
<div <nav
className={classNames({ className={classNames({
PartyNavigation: true, [styles.nav]: true,
Editable: party.editable,
})} })}
> >
<SegmentedControl elementClass={getElement()}> <SegmentedControl gap={true} grow={true} elementClass={getElement()}>
{characterSegment()} {characterSegment()}
{weaponSegment()} {weaponSegment()}
{summonSegment()} {summonSegment()}
</SegmentedControl> </SegmentedControl>
</div> </nav>
) )
} }

View file

@ -1,15 +1,27 @@
.CharacterRep { .rep {
aspect-ratio: 2/0.99; aspect-ratio: 2/0.99;
border-radius: $card-corner; border-radius: $card-corner;
grid-gap: $unit-half; /* add a gap of 8px between grid items */ grid-gap: $unit-half; /* add a gap of 8px between grid items */
height: $rep-height; height: $rep-height;
transition: $duration-opacity-fade opacity ease-in;
opacity: 0.5;
.Character { .character,
.protagonist {
aspect-ratio: 16 / 33;
background: var(--card-bg); background: var(--card-bg);
border-radius: 4px; border-radius: 4px;
box-sizing: border-box;
display: grid;
overflow: hidden;
img[src*='jpg'] {
border-radius: 4px;
width: 100%;
}
} }
.GridCharacters { .characters {
display: grid; /* make the right-images container a grid */ display: grid; /* make the right-images container a grid */
grid-template-columns: repeat( grid-template-columns: repeat(
4, 4,
@ -18,13 +30,7 @@
gap: $unit-half; gap: $unit-half;
} }
.Grid.Character { .protagonist {
aspect-ratio: 16 / 33;
box-sizing: border-box;
display: grid;
overflow: hidden;
&.MC {
border-color: transparent; border-color: transparent;
border-width: 1px; border-width: 1px;
border-style: solid; border-style: solid;
@ -67,9 +73,3 @@
} }
} }
} }
.Grid.Character img[src*='jpg'] {
border-radius: 4px;
width: 100%;
}
}

View file

@ -4,6 +4,7 @@ import { useTranslation } from 'next-i18next'
import 'fix-date' import 'fix-date'
import styles from './index.module.scss' import styles from './index.module.scss'
import classNames from 'classnames'
interface Props { interface Props {
job?: Job job?: Job
@ -109,17 +110,20 @@ const CharacterRep = (props: Props) => {
// Render // Render
return ( return (
<div className="CharacterRep Rep"> <div className={styles.rep}>
<ul className="GridCharacters"> <ul className={styles.characters}>
<li <li
key="characters-job" key="characters-job"
className={`Grid Character MC ${numberToElement()}`} className={classNames({
[styles.protagonist]: true,
[styles[`${numberToElement()}`]]: true,
})}
> >
{generateMCImage()} {generateMCImage()}
</li> </li>
{Array.from(Array(CHARACTERS_COUNT)).map((x, i) => { {Array.from(Array(CHARACTERS_COUNT)).map((x, i) => {
return ( return (
<li key={`characters-${i}`} className="Grid Character"> <li key={`characters-${i}`} className={styles.character}>
{generateGridImage(i)} {generateGridImage(i)}
</li> </li>
) )

View file

@ -1,4 +1,4 @@
.RepSegment { .segment {
border-radius: $card-corner; border-radius: $card-corner;
color: $grey-55; color: $grey-55;
cursor: pointer; cursor: pointer;
@ -10,7 +10,7 @@
background: var(--button-bg); background: var(--button-bg);
color: var(--text-primary); color: var(--text-primary);
.Wrapper .Rep { .wrapper > * {
opacity: 1; opacity: 1;
} }
} }
@ -22,7 +22,7 @@
background: var(--button-bg); background: var(--button-bg);
color: var(--text-primary); color: var(--text-primary);
.Rep { .wrapper > * {
opacity: 1; opacity: 1;
} }
} }
@ -50,15 +50,10 @@
padding-bottom: $unit; padding-bottom: $unit;
} }
.Wrapper { .wrapper {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: $unit; gap: $unit;
.Rep {
transition: $duration-opacity-fade opacity ease-in;
opacity: 0.5;
}
} }
} }
@ -66,7 +61,7 @@
min-width: initial; min-width: initial;
width: 100%; width: 100%;
.Rep { .rep {
display: none; display: none;
} }
} }

View file

@ -12,7 +12,7 @@ interface Props {
const RepSegment = ({ children, ...props }: PropsWithChildren<Props>) => { const RepSegment = ({ children, ...props }: PropsWithChildren<Props>) => {
return ( return (
<div className="RepSegment"> <div className={styles.segment}>
<input <input
name={props.controlGroup} name={props.controlGroup}
id={props.inputName} id={props.inputName}
@ -22,9 +22,9 @@ const RepSegment = ({ children, ...props }: PropsWithChildren<Props>) => {
onChange={props.onClick} onChange={props.onClick}
/> />
<label htmlFor={props.inputName}> <label htmlFor={props.inputName}>
<div className="Wrapper"> <div className={styles.wrapper}>
{children} {children}
<div className="Title">{props.name}</div> <div className={styles.title}>{props.name}</div>
</div> </div>
</label> </label>
</div> </div>

View file

@ -1,23 +1,31 @@
.SummonRep { .rep {
aspect-ratio: 2/1.045; aspect-ratio: 2/1.045;
border-radius: $card-corner; border-radius: $card-corner;
display: grid; display: grid;
grid-template-columns: 1fr 2.25fr; /* left column takes up 1 fraction, right column takes up 3 fractions */ grid-template-columns: 1fr 2.25fr; /* left column takes up 1 fraction, right column takes up 3 fractions */
grid-gap: $unit-half; /* add a gap of 8px between grid items */ grid-gap: $unit-half; /* add a gap of 8px between grid items */
height: $rep-height; height: $rep-height;
transition: $duration-opacity-fade opacity ease-in;
opacity: 0.5;
.Summon { .summon,
.mainSummon {
background: var(--card-bg); background: var(--card-bg);
border-radius: 4px; border-radius: 4px;
img[src*='jpg'] {
border-radius: 4px;
width: 100%;
}
} }
.Main.Summon { .mainSummon {
aspect-ratio: 56/97; aspect-ratio: 56/97;
display: grid; display: grid;
grid-column: 1 / 2; /* spans one column */ grid-column: 1 / 2; /* spans one column */
} }
.GridSummons { .summons {
display: grid; /* make the right-images container a grid */ display: grid; /* make the right-images container a grid */
grid-template-columns: repeat( grid-template-columns: repeat(
2, 2,
@ -32,14 +40,8 @@
// row-gap: $unit-2x; // row-gap: $unit-2x;
} }
.Grid.Summon { .summon {
aspect-ratio: 184 / 138; aspect-ratio: 184 / 138;
display: grid; display: grid;
} }
.Main.Summon img[src*='jpg'],
.Grid.Summon img[src*='jpg'] {
border-radius: 4px;
width: 100%;
}
} }

View file

@ -151,12 +151,12 @@ const SummonRep = (props: Props) => {
// Render // Render
return ( return (
<div className="SummonRep Rep"> <div className={styles.rep}>
<div className="Main Summon">{generateMainImage()}</div> <div className={styles.mainSummon}>{generateMainImage()}</div>
<ul className="GridSummons"> <ul className={styles.summons}>
{Array.from(Array(SUMMONS_COUNT)).map((x, i) => { {Array.from(Array(SUMMONS_COUNT)).map((x, i) => {
return ( return (
<li key={`summons-${i}`} className="Grid Summon"> <li key={`summons-${i}`} className={styles.summon}>
{generateGridImage(i)} {generateGridImage(i)}
</li> </li>
) )

View file

@ -1,23 +1,31 @@
.WeaponRep { .rep {
aspect-ratio: 2/0.955; aspect-ratio: 2/0.955;
border-radius: $card-corner; border-radius: $card-corner;
display: grid; display: grid;
grid-template-columns: 1fr 3.39fr; /* left column takes up 1 fraction, right column takes up 3 fractions */ grid-template-columns: 1fr 3.39fr; /* left column takes up 1 fraction, right column takes up 3 fractions */
grid-gap: $unit-half; /* add a gap of 8px between grid items */ grid-gap: $unit-half; /* add a gap of 8px between grid items */
height: $rep-height; height: $rep-height;
transition: $duration-opacity-fade opacity ease-in;
opacity: 0.5;
.Weapon { .mainhand,
.weapon {
background: var(--card-bg); background: var(--card-bg);
border-radius: 4px; border-radius: 4px;
img[src*='jpg'] {
border-radius: 4px;
width: 100%;
}
} }
.Mainhand.Weapon { .mainhand {
aspect-ratio: 73/153; aspect-ratio: 73/153;
display: grid; display: grid;
grid-column: 1 / 2; /* spans one column */ grid-column: 1 / 2; /* spans one column */
} }
.GridWeapons { .weapons {
display: grid; /* make the right-images container a grid */ display: grid; /* make the right-images container a grid */
grid-template-columns: repeat( grid-template-columns: repeat(
3, 3,
@ -32,14 +40,8 @@
// row-gap: $unit-2x; // row-gap: $unit-2x;
} }
.Grid.Weapon { .weapon {
aspect-ratio: 280 / 160; aspect-ratio: 280 / 160;
display: grid; display: grid;
} }
.Mainhand.Weapon img[src*='jpg'],
.Grid.Weapon img[src*='jpg'] {
border-radius: 4px;
width: 100%;
}
} }

View file

@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import styles from './index.module.scss' import styles from './index.module.scss'
import classNames from 'classnames'
interface Props { interface Props {
grid: { grid: {
@ -85,12 +86,12 @@ const WeaponRep = (props: Props) => {
// Render // Render
return ( return (
<div className="WeaponRep Rep"> <div className={styles.rep}>
<div className="Mainhand Weapon">{generateMainhandImage()}</div> <div className={styles.mainhand}>{generateMainhandImage()}</div>
<ul className="GridWeapons"> <ul className={styles.weapons}>
{Array.from(Array(WEAPONS_COUNT)).map((x, i) => { {Array.from(Array(WEAPONS_COUNT)).map((x, i) => {
return ( return (
<li key={`weapons-${i}`} className="Grid Weapon"> <li key={`weapons-${i}`} className={styles.weapon}>
{generateGridImage(i)} {generateGridImage(i)}
</li> </li>
) )