Added RepSegment

This is a Character, Weapon or Summon rep wrapped with an input and label for use in a SegmentedControl
This commit is contained in:
Justin Edmund 2023-04-16 03:49:21 -07:00
parent bad870a546
commit 1c09a5cc9c
2 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,62 @@
.RepSegment {
border-radius: $card-corner;
color: $grey-55;
cursor: pointer;
font-size: 1.4rem;
font-weight: $normal;
min-width: 100px;
&:hover label {
background: var(--button-bg);
color: var(--text-primary);
.Wrapper .Rep {
opacity: 1;
}
}
& input {
display: none;
&:checked + label {
background: var(--button-bg);
color: var(--text-primary);
.Rep {
opacity: 1;
}
}
}
& label {
border-radius: $card-corner;
display: block;
text-align: center;
white-space: nowrap;
overflow: hidden;
padding: $unit;
padding-bottom: $unit * 1.5;
text-overflow: ellipsis;
cursor: pointer;
&:before {
background: #fff;
}
.Wrapper {
display: flex;
flex-direction: column;
gap: $unit;
.Rep {
transition: $duration-opacity-fade opacity ease-in;
opacity: 0.5;
}
}
}
@include breakpoint(phone) {
min-width: initial;
width: 100%;
}
}

View file

@ -0,0 +1,34 @@
import React, { PropsWithChildren } from 'react'
import './index.scss'
interface Props {
controlGroup: string
inputName: string
name: string
selected: boolean
onClick: (event: React.ChangeEvent<HTMLInputElement>) => void
}
const RepSegment = ({ children, ...props }: PropsWithChildren<Props>) => {
return (
<div className="RepSegment">
<input
name={props.controlGroup}
id={props.inputName}
value={props.inputName}
type="radio"
checked={props.selected}
onChange={props.onClick}
/>
<label htmlFor={props.inputName}>
<div className="Wrapper">
{children}
<div className="Title">{props.name}</div>
</div>
</label>
</div>
)
}
export default RepSegment