mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 11:59:11 +00:00
* miniflare init * feat(api): add tests * chore: more tests, almost 100% * add sessions/state spec * add majority of routes and datapaths, start on interactions * nevermind, no interactions * nevermind x2, tweetnacl is bad but SubtleCrypto has what we need apparently * simplify interactions verify * add brute force interactions tests * every primary path API route is refactored! * automatically import from legacy, or die trying. * check that we only fetch legacy once, ever * remove old-src, same some historic pieces * remove interactions & worker-utils package, update misc/types * update some packages we don't need specific pinning for anymore * update web references to API routes since they all changed * fix all linting issues, upgrade most packages * fix tests, divorce enzyme where-ever possible * update web, fix integration issues * pre-build api * fix tests * move api pretest to api package.json instead of CI * remove interactions from terraform, fix deploy side configs * update to tf 1.1.4 * prevent double writes to worker in GCS, port to newer GCP auth workflow * fix api.tf var refs, upgrade node action * change to curl-based script upload for worker script due to terraform provider limitations * oh no, cloudflare freaked out :(
122 lines
2.7 KiB
TypeScript
122 lines
2.7 KiB
TypeScript
import { palette } from '@roleypoly/design-system/atoms/colors';
|
|
import { fontCSS } from '@roleypoly/design-system/atoms/fonts';
|
|
import * as React from 'react';
|
|
import styled, { css } from 'styled-components';
|
|
|
|
const common = css`
|
|
appearance: none;
|
|
border: 1px solid ${palette.taupe200};
|
|
border-radius: 3px;
|
|
line-height: 163%;
|
|
padding: 12px 16px;
|
|
font-size: 1.2rem;
|
|
background-color: ${palette.taupe300};
|
|
color: ${palette.grey600};
|
|
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
position: relative;
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
max-width: 97vw;
|
|
|
|
:focus {
|
|
outline: none;
|
|
border-color: ${palette.grey100};
|
|
box-shadow: 1px 0 3px rgb(0 0 0 / 25%);
|
|
}
|
|
|
|
[disabled],
|
|
:disabled {
|
|
cursor: not-allowed;
|
|
color: rgb(255 255 255 / 75%);
|
|
font-style: italic;
|
|
}
|
|
|
|
:hover:not([disabled]) {
|
|
border-color: ${palette.grey100};
|
|
}
|
|
|
|
::placeholder {
|
|
color: ${palette.taupe500};
|
|
}
|
|
`;
|
|
|
|
export const StyledTextInput = styled.input`
|
|
${common}
|
|
`;
|
|
|
|
type TextInputProps<T extends HTMLInputElement | HTMLTextAreaElement> =
|
|
React.InputHTMLAttributes<T>;
|
|
|
|
export const TextInput = (props: TextInputProps<HTMLInputElement>) => {
|
|
const { ...rest } = props;
|
|
return <StyledTextInput {...rest} />;
|
|
};
|
|
|
|
const StyledTextInputWithIcon = styled(StyledTextInput)`
|
|
padding-left: 36px;
|
|
`;
|
|
|
|
const IconContainer = styled.div`
|
|
position: absolute;
|
|
left: 12px;
|
|
top: 0;
|
|
bottom: 0;
|
|
z-index: 1;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
`;
|
|
|
|
const IconInputContainer = styled.div`
|
|
position: relative;
|
|
width: 100%;
|
|
`;
|
|
|
|
type TextInputWithIconProps = TextInputProps<HTMLInputElement> & {
|
|
icon: React.ReactNode;
|
|
};
|
|
|
|
export const TextInputWithIcon = (props: TextInputWithIconProps) => {
|
|
const { icon, ...rest } = props;
|
|
return (
|
|
<IconInputContainer>
|
|
<IconContainer>{icon}</IconContainer>
|
|
<StyledTextInputWithIcon {...rest}></StyledTextInputWithIcon>
|
|
</IconInputContainer>
|
|
);
|
|
};
|
|
|
|
const StyledTextarea = styled.textarea`
|
|
${common}
|
|
${fontCSS}
|
|
|
|
margin: 0.5em 0;
|
|
`;
|
|
|
|
export const MultilineTextInput = (
|
|
props: TextInputProps<HTMLTextAreaElement> & { rows?: number }
|
|
) => {
|
|
const { children, ...rest } = props;
|
|
const [value, setValue] = React.useState(String(props.value));
|
|
const rows = React.useMemo(
|
|
() => Math.min(10, Math.max(props.rows || 2, value.split(/\r?\n/).length)),
|
|
[value]
|
|
);
|
|
|
|
React.useEffect(() => {
|
|
setValue(String(props.value));
|
|
}, [props.value]);
|
|
|
|
return (
|
|
<StyledTextarea
|
|
{...rest}
|
|
rows={rows}
|
|
onChange={(eventData) => {
|
|
setValue(eventData.target.value);
|
|
props.onChange?.(eventData);
|
|
}}
|
|
>
|
|
{value}
|
|
</StyledTextarea>
|
|
);
|
|
};
|