-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
118 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { NumberInput, NumberProps } from './Number'; | ||
import { BaseProperty, BasePropertyProps } from '../BaseProperty'; | ||
|
||
export interface Vector2Props extends BasePropertyProps { | ||
x: NumberProps; | ||
y: NumberProps; | ||
onChange: (value: [number, number]) => void; | ||
value: [number, number]; | ||
} | ||
|
||
const Vector2Container = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
`; | ||
|
||
export const Vector2: React.FC<Vector2Props> = ({ x, y, label, onChange, value }) => { | ||
x.onChange = (value: number) => { | ||
console.log('x.onChange', value, y.value); | ||
onChange(JSON.stringify([value, y.value])) | ||
} | ||
y.onChange = (value: number) => { | ||
onChange(JSON.stringify([x.value, value])) | ||
} | ||
|
||
x.value = value[0]; | ||
y.value = value[1]; | ||
|
||
return ( | ||
<BaseProperty label={label}> | ||
<Vector2Container> | ||
<NumberInput {...x} /> | ||
<NumberInput {...y} /> | ||
</Vector2Container> | ||
</BaseProperty> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { BaseProperty, BasePropertyProps } from '../BaseProperty'; | ||
|
||
export interface TextProps extends BasePropertyProps { | ||
value: string; | ||
onChange: (value: string) => void; | ||
disabled?: boolean; | ||
} | ||
|
||
const StyledNumberRoot = styled.input` | ||
width: 200px; | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 4px; | ||
padding: 0 10px; | ||
height: 35px; | ||
font-size: 15px; | ||
line-height: 1; | ||
color: white; | ||
background-color: var(--darkest-color); | ||
box-shadow: 0 0 0 1px black; | ||
&:focus { | ||
box-shadow: 0 0 0 2px var(--secondary-color); | ||
} | ||
&::selection { | ||
background-color: var(--secondary-color); | ||
color: white; | ||
} | ||
`; | ||
|
||
export const TextInput: React.FC<TextProps> = ({ value, onChange, label, ...rest }) => { | ||
return ( | ||
<BaseProperty label={label}> | ||
<StyledNumberRoot | ||
type="text" | ||
value={value} | ||
onChange={(event) => onChange(JSON.stringify(event.target.value))} | ||
{...rest} | ||
/> | ||
</BaseProperty> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters