Skip to content

Commit

Permalink
Merge branch 'main' into beta-notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
KaWaite committed Nov 8, 2023
2 parents a1ea294 + 7c5587d commit 5987f74
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
3 changes: 0 additions & 3 deletions server/pkg/builtin/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2310,9 +2310,6 @@ extensions:
type: number
suffix: px
defaultValue: 20
- id: background
title: background Setting
type: string
- id: title
title: Title Setting
fields:
Expand Down
10 changes: 7 additions & 3 deletions web/src/beta/components/fields/SliderField/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ type Story = StoryObj<typeof SliderField>;
export const Default: Story = (args: Props) => {
const [_, updateArgs] = useArgs();

const handleChange = useCallback((value: number) => updateArgs({ value: value }), [updateArgs]);
const handleChange = useCallback(
(value: number) => {
updateArgs({ value: value });
},
[updateArgs],
);

return (
<Wrapper>
Expand Down Expand Up @@ -50,8 +55,7 @@ const Wrapper = styled.div`
display: flex;
flex-direction: column;
gap: 10%;
margin-left: 2rem;
margin-top: 2rem;
margin: 2rem;
height: 300px;
`;

Expand Down
19 changes: 17 additions & 2 deletions web/src/beta/components/fields/SliderField/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useCallback, useEffect, useState } from "react";

import Property from "@reearth/beta/components/fields";
import Slider, { Props as SliderProps } from "@reearth/beta/components/Slider";

Expand All @@ -6,10 +8,23 @@ export type Props = {
description?: string;
} & SliderProps;

const SliderField: React.FC<Props> = ({ name, description, ...args }: Props) => {
const SliderField: React.FC<Props> = ({ name, description, value, onChange, ...args }: Props) => {
const [internalState, setInternalState] = useState(value);

const handleChange = useCallback(
(value: number) => {
setInternalState(value);
},
[setInternalState],
);

useEffect(() => {
setInternalState(value);
}, [value]);

return (
<Property name={name} description={description}>
<Slider {...args} />
<Slider value={internalState} onChange={handleChange} onAfterChange={onChange} {...args} />
</Property>
);
};
Expand Down

0 comments on commit 5987f74

Please sign in to comment.