-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎛️ Integrate the crt constraints proposal (#4822)
* Make the NumberOfBlocks renderer reusable * Preview CRT constraints proposal * Create CRT constraints proposal * Query `UpdateTokenPalletTokenConstraintsProposalDetails` * Schema and types * Show current values in the form * Show current values on the preview page * Fix the vote on proposal modal * Fix mismatched values * Show current values on field inputs sub label instead of message So the current values remain visible while input values are invalid * Enable decimal values in `InputNumber` * Use decimal percent to represent part per million * Preview decimal percents
- Loading branch information
Showing
32 changed files
with
12,855 additions
and
417 deletions.
There are no files selected for viewing
12,405 changes: 12,051 additions & 354 deletions
12,405
.yarn/patches/@joystream-types-npm-4.3.0-542438a0b6.patch
Large diffs are not rendered by default.
Oops, something went wrong.
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
23 changes: 23 additions & 0 deletions
23
packages/ui/src/common/api/queries/__generated__/baseTypes.generated.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
57 changes: 57 additions & 0 deletions
57
packages/ui/src/common/components/forms/InputNumber.stories.tsx
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,57 @@ | ||
import { Meta, StoryObj } from '@storybook/react' | ||
import React, { FC, useEffect } from 'react' | ||
import { useFormContext } from 'react-hook-form' | ||
|
||
import { InputComponent } from './InputComponent' | ||
import { InputNumber } from './InputNumber' | ||
|
||
type Args = { | ||
maxAllowedValue: number | ||
placeholder: string | ||
label: string | ||
units: string | ||
decimalScale: number | ||
onChange: (value: number) => void | ||
} | ||
type Story = StoryObj<FC<Args>> | ||
|
||
export default { | ||
title: 'Common/Forms/InputNumber', | ||
component: InputNumber as unknown as FC<Args>, | ||
|
||
argTypes: { | ||
onChange: { action: 'onChange' }, | ||
}, | ||
|
||
args: { | ||
maxAllowedValue: 10_000, | ||
placeholder: '0', | ||
label: 'Amount', | ||
units: 'per 10 000', | ||
decimalScale: 2, | ||
}, | ||
} satisfies Meta<Args> | ||
|
||
export const InputNumberStory: Story = { | ||
name: 'InputNumber', | ||
render: ({ label, units, onChange, ...props }) => { | ||
const form = useFormContext() | ||
|
||
useEffect(() => { | ||
const subscription = form.watch((data) => onChange(data.input)) | ||
return () => subscription.unsubscribe() | ||
}, [form.watch]) | ||
|
||
return ( | ||
<InputComponent | ||
id="input" | ||
label={label} | ||
units={units} | ||
message={`Value must be between 0 and ${props.maxAllowedValue}.`} | ||
tight | ||
> | ||
<InputNumber {...props} id="input" name="input" /> | ||
</InputComponent> | ||
) | ||
}, | ||
} |
Oops, something went wrong.