1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-26 11:49:04 +01:00
This commit is contained in:
Matthias Kretschmann 2023-11-04 00:16:38 +00:00
parent afb2b16e69
commit ae73bfc925
Signed by: m
GPG Key ID: 606EEEF3C479A91F
5 changed files with 76 additions and 56 deletions

View File

@ -1,82 +1,99 @@
.inputGroup { .inputGroup {
--height: 50px; --height: 50px;
--border: var(--border-width) solid var(--border-color);
--tokenWidth: 75px;
margin: auto; margin: auto;
position: relative;
margin-top: calc(var(--spacer) / 3); margin-top: calc(var(--spacer) / 3);
display: flex;
flex-direction: column;
min-height: var(--height); min-height: var(--height);
border-radius: var(--border-radius);
border: var(--border);
overflow: hidden;
transition: border-color 0.2s ease-out;
position: relative;
} }
@media (min-width: 40rem) { @media (min-width: 25rem) {
.inputGroup { .inputGroup {
flex-direction: row;
}
}
.inputWrap {
display: flex; display: flex;
flex-direction: row;
align-items: center; align-items: center;
} }
:global([data-theme='dark']) .inputGroup {
border-color: var(--border-color);
}
}
.inputGroup.focus {
/* box-shadow: 0 0 0 1px var(--input-border-focus); */
border-color: var(--input-border-focus);
}
.token { .token {
width: 90px; position: absolute;
height: var(--height); left: 0;
top: 0;
width: var(--tokenWidth);
height: calc(var(--height) - var(--border-width));
background: var(--box-background-color); background: var(--box-background-color);
border-top-left-radius: var(--border-radius); border-top-left-radius: var(--border-radius);
border-bottom-left-radius: var(--border-radius); border-bottom-left-radius: var(--border-radius);
border: var(--border-width) solid var(--border-color); display: flex;
border-right-color: var(--box-background-color); align-items: center;
} }
.inputInput { .inputInput {
text-align: center; text-align: center;
border: var(--border-width) solid var(--border-color); border: 0;
font-size: var(--font-size-large); font-size: var(--font-size-large);
padding: 0 calc(var(--spacer) / 4); padding: 0;
border-bottom: 0; padding-left: var(--tokenWidth);
border-bottom-left-radius: 0; border-bottom-left-radius: 0;
border-bottom-right-radius: 0; border-bottom-right-radius: 0;
border-bottom: var(--border);
height: var(--height); height: var(--height);
width: 100%;
}
.inputInput:focus {
border: 0;
}
@media (min-width: 25rem) {
.token {
height: 100%;
} }
@media (min-width: 40rem) {
.inputInput { .inputInput {
border-radius: 0; border-radius: 0;
border-bottom: var(--border-width) solid var(--border-color); border-bottom: 0;
width: 70%;
} }
} }
:global([data-theme='dark']) .inputInput {
border-color: var(--border-color);
}
.submit { .submit {
width: 100%;
max-width: none; max-width: none;
height: calc(var(--height) - calc(var(--border-width) * 2)); height: calc(var(--height) - 2px);
border-top-left-radius: 0; border-top-left-radius: 0;
border-top-right-radius: 0; border-top-right-radius: 0;
border: var(--border-width) solid var(--link-color); border: 0;
padding-top: 0; padding: 0;
padding-bottom: 0; box-shadow: none;
} }
@media (min-width: 40rem) { @media (min-width: 25rem) {
.submit { .submit {
width: fit-content; width: fit-content;
padding: 0 calc(var(--spacer) / 1.5);
border-top-right-radius: var(--border-radius); border-top-right-radius: var(--border-radius);
border-top-left-radius: 0; border-top-left-radius: 0;
border-bottom-left-radius: 0; border-bottom-left-radius: 0;
border-left: 0; margin-right: 1px;
} }
} }
/* .submit:disabled { .submit:disabled {
opacity: 0.8; background: var(--box-background-color);
background: var(--text-color-light); color: var(--text-color-light);
color: var(--text-color); text-shadow: none;
border-color: var(--text-color-light); }
} */

View File

@ -1,4 +1,4 @@
import { type ReactElement } from 'react' import { useState, type ReactElement } from 'react'
import Input from '@components/Input' import Input from '@components/Input'
import { Conversion } from '../Conversion' import { Conversion } from '../Conversion'
import styles from './InputGroup.module.css' import styles from './InputGroup.module.css'
@ -14,14 +14,14 @@ export function InputGroup({
const amount = useStore($amount) const amount = useStore($amount)
const selectedToken = useStore($selectedToken) const selectedToken = useStore($selectedToken)
const [isFocus, setIsFocus] = useState(false)
function handleChange(newAmount: string) { function handleChange(newAmount: string) {
$amount.set(newAmount) $amount.set(newAmount)
} }
return ( return (
<> <>
<div className={styles.inputGroup}> <div className={`${styles.inputGroup} ${isFocus ? styles.focus : ''}`}>
<div className={styles.inputWrap}>
<div className={styles.token}> <div className={styles.token}>
<TokenSelect /> <TokenSelect />
</div> </div>
@ -32,10 +32,10 @@ export function InputGroup({
value={amount} value={amount}
placeholder="0.00" placeholder="0.00"
onChange={(e) => handleChange(e.target.value)} onChange={(e) => handleChange(e.target.value)}
onFocus={() => setIsFocus(true)}
onBlur={() => setIsFocus(false)}
className={styles.inputInput} className={styles.inputInput}
/> />
</div>
<button <button
className={`${styles.submit} btn btn-primary`} className={`${styles.submit} btn btn-primary`}
disabled={isDisabled || !amount || !selectedToken} disabled={isDisabled || !amount || !selectedToken}
@ -44,6 +44,7 @@ export function InputGroup({
Preview Preview
</button> </button>
</div> </div>
<Conversion /> <Conversion />
</> </>
) )

View File

@ -10,7 +10,7 @@
.actions button:first-child { .actions button:first-child {
margin-right: var(--spacer); margin-right: var(--spacer);
width: 115px; width: 115px;
height: 50px; height: 45px;
padding-top: 0; padding-top: 0;
padding-bottom: 0; padding-bottom: 0;
} }

View File

@ -11,11 +11,13 @@
} }
.SelectTrigger:hover { .SelectTrigger:hover {
background-color: var(--box-background-color); background-color: var(--text-color-dimmed);
} }
.SelectTrigger:focus { .SelectTrigger:focus {
box-shadow: 0 0 0 var(--border-width) var(--input-border-focus); background-color: var(--text-color-dimmed);
/* box-shadow: 0 0 0 var(--border-width) var(--input-border-focus); */
/* border-color: var(--input-border-focus) !important; */ /* border-color: var(--input-border-focus) !important; */
} }

View File

@ -114,7 +114,7 @@
--input-color-placeholder: var(--text-color-light); --input-color-placeholder: var(--text-color-light);
--input-border: var(--border-color); --input-border: var(--border-color);
--input-border-focus: var(--brand-cyan); --input-border-focus: var(--link-color);
/* Misc. /* Misc.
///////////////////////////////////// */ ///////////////////////////////////// */