Update AxSelect for CSS modules
This commit is contained in:
parent
c65b2597aa
commit
fab8ab260c
2 changed files with 43 additions and 43 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
.AXSelect {
|
.ax {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: $unit;
|
gap: $unit;
|
||||||
|
|
||||||
.AXSet {
|
.set {
|
||||||
&.hidden {
|
&.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
@ -22,26 +22,6 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
gap: $unit;
|
gap: $unit;
|
||||||
|
|
||||||
.SelectTrigger {
|
|
||||||
flex-grow: 1;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
border: none;
|
|
||||||
border-radius: $input-corner;
|
|
||||||
box-sizing: border-box;
|
|
||||||
display: none;
|
|
||||||
text-align: right;
|
|
||||||
min-width: $unit-14x;
|
|
||||||
width: 100px;
|
|
||||||
|
|
||||||
&.Visible {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import React, { ForwardedRef, useEffect, useState } from 'react'
|
import React, { useEffect, useState } from 'react'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
|
|
||||||
|
import Input from '~components/common/Input'
|
||||||
import Select from '~components/common/Select'
|
import Select from '~components/common/Select'
|
||||||
import SelectItem from '~components/common/SelectItem'
|
import SelectItem from '~components/common/SelectItem'
|
||||||
|
|
||||||
|
|
@ -45,14 +46,19 @@ const AXSelect = (props: Props) => {
|
||||||
axValue2: '',
|
axValue2: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const inputClasses = classNames({
|
||||||
|
fullHeight: true,
|
||||||
|
range: true,
|
||||||
|
})
|
||||||
|
|
||||||
const primaryErrorClasses = classNames({
|
const primaryErrorClasses = classNames({
|
||||||
errors: true,
|
[styles.errors]: true,
|
||||||
visible: errors.axValue1.length > 0,
|
[styles.visible]: errors.axValue1.length > 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
const secondaryErrorClasses = classNames({
|
const secondaryErrorClasses = classNames({
|
||||||
errors: true,
|
[styles.errors]: true,
|
||||||
visible: errors.axValue2.length > 0,
|
[styles.visible]: errors.axValue2.length > 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Refs
|
// Refs
|
||||||
|
|
@ -139,8 +145,8 @@ const AXSelect = (props: Props) => {
|
||||||
|
|
||||||
// Classes
|
// Classes
|
||||||
const secondarySetClasses = classNames({
|
const secondarySetClasses = classNames({
|
||||||
AXSet: true,
|
[styles.set]: true,
|
||||||
hidden: primaryAxModifier < 0,
|
[styles.hidden]: primaryAxModifier < 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
function setupAx1() {
|
function setupAx1() {
|
||||||
|
|
@ -271,7 +277,7 @@ const AXSelect = (props: Props) => {
|
||||||
// Reset the secondary AX modifier, reset the AX value and hide the input
|
// Reset the secondary AX modifier, reset the AX value and hide the input
|
||||||
setSecondaryAxModifier(-1)
|
setSecondaryAxModifier(-1)
|
||||||
setSecondaryAxValue(0)
|
setSecondaryAxValue(0)
|
||||||
secondaryAxValueInput.current.className = 'Input Contained'
|
// secondaryAxValueInput.current.className = 'Input Contained'
|
||||||
secondaryAxValueInput.current.value = ''
|
secondaryAxValueInput.current.value = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -377,7 +383,7 @@ const AXSelect = (props: Props) => {
|
||||||
if (ax) {
|
if (ax) {
|
||||||
const rangeString = `${ax.minValue}~${ax.maxValue}${ax.suffix || ''}`
|
const rangeString = `${ax.minValue}~${ax.maxValue}${ax.suffix || ''}`
|
||||||
|
|
||||||
element.className = 'Input Bound Visible'
|
// element.className = 'Input Bound Visible'
|
||||||
element.disabled = false
|
element.disabled = false
|
||||||
element.placeholder = rangeString
|
element.placeholder = rangeString
|
||||||
element.min = `${ax.minValue}`
|
element.min = `${ax.minValue}`
|
||||||
|
|
@ -386,12 +392,12 @@ const AXSelect = (props: Props) => {
|
||||||
} else {
|
} else {
|
||||||
if (primaryAxValueInput.current && secondaryAxValueInput.current) {
|
if (primaryAxValueInput.current && secondaryAxValueInput.current) {
|
||||||
if (primaryAxValueInput.current == element) {
|
if (primaryAxValueInput.current == element) {
|
||||||
primaryAxValueInput.current.className = 'Input Contained'
|
// primaryAxValueInput.current.className = 'Input Contained'
|
||||||
primaryAxValueInput.current.disabled = true
|
primaryAxValueInput.current.disabled = true
|
||||||
primaryAxValueInput.current.placeholder = ''
|
primaryAxValueInput.current.placeholder = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
secondaryAxValueInput.current.className = 'Input Contained'
|
// secondaryAxValueInput.current.className = 'Input Contained'
|
||||||
secondaryAxValueInput.current.disabled = true
|
secondaryAxValueInput.current.disabled = true
|
||||||
secondaryAxValueInput.current.placeholder = ''
|
secondaryAxValueInput.current.placeholder = ''
|
||||||
}
|
}
|
||||||
|
|
@ -399,24 +405,31 @@ const AXSelect = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="AXSelect">
|
<div className={styles.ax}>
|
||||||
<div className="AXSet">
|
<div className={styles.set}>
|
||||||
<div className="fields">
|
<div className={styles.fields}>
|
||||||
<Select
|
<Select
|
||||||
key="ax1"
|
key="ax1"
|
||||||
value={`${primaryAxModifier}`}
|
value={`${primaryAxModifier}`}
|
||||||
open={openAX1}
|
open={openAX1}
|
||||||
|
trigger={{
|
||||||
|
className: 'grow',
|
||||||
|
}}
|
||||||
onClose={() => onClose(1)}
|
onClose={() => onClose(1)}
|
||||||
onOpenChange={() => openSelect(1)}
|
onOpenChange={() => openSelect(1)}
|
||||||
onValueChange={handleAX1SelectChange}
|
onValueChange={handleAX1SelectChange}
|
||||||
triggerClass="modal"
|
|
||||||
overlayVisible={false}
|
overlayVisible={false}
|
||||||
>
|
>
|
||||||
{generateOptions(0)}
|
{generateOptions(0)}
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
<input
|
<Input
|
||||||
defaultValue={
|
className={inputClasses}
|
||||||
|
wrapperClassName="fullHeight"
|
||||||
|
fieldsetClassName={classNames({
|
||||||
|
hidden: primaryAxModifier < 0,
|
||||||
|
})}
|
||||||
|
value={
|
||||||
props.currentSkills && props.currentSkills[0]
|
props.currentSkills && props.currentSkills[0]
|
||||||
? props.currentSkills[0].strength
|
? props.currentSkills[0].strength
|
||||||
: 0
|
: 0
|
||||||
|
|
@ -430,22 +443,29 @@ const AXSelect = (props: Props) => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={secondarySetClasses}>
|
<div className={secondarySetClasses}>
|
||||||
<div className="fields">
|
<div className={styles.fields}>
|
||||||
<Select
|
<Select
|
||||||
key="ax2"
|
key="ax2"
|
||||||
value={`${secondaryAxModifier}`}
|
value={`${secondaryAxModifier}`}
|
||||||
open={openAX2}
|
open={openAX2}
|
||||||
|
trigger={{
|
||||||
|
className: 'grow',
|
||||||
|
}}
|
||||||
onClose={() => onClose(2)}
|
onClose={() => onClose(2)}
|
||||||
onOpenChange={() => openSelect(2)}
|
onOpenChange={() => openSelect(2)}
|
||||||
onValueChange={handleAX2SelectChange}
|
onValueChange={handleAX2SelectChange}
|
||||||
triggerClass="modal"
|
|
||||||
ref={secondaryAxModifierSelect}
|
ref={secondaryAxModifierSelect}
|
||||||
overlayVisible={false}
|
overlayVisible={false}
|
||||||
>
|
>
|
||||||
{generateOptions(1)}
|
{generateOptions(1)}
|
||||||
</Select>
|
</Select>
|
||||||
<input
|
<Input
|
||||||
defaultValue={
|
className={inputClasses}
|
||||||
|
wrapperClassName="fullHeight"
|
||||||
|
fieldsetClassName={classNames({
|
||||||
|
hidden: secondaryAxModifier < 0,
|
||||||
|
})}
|
||||||
|
value={
|
||||||
props.currentSkills && props.currentSkills[1]
|
props.currentSkills && props.currentSkills[1]
|
||||||
? props.currentSkills[1].strength
|
? props.currentSkills[1].strength
|
||||||
: 0
|
: 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue