Skip to content

Commit

Permalink
Float-ui (#848)
Browse files Browse the repository at this point in the history
* fix: check if element exists

* fix: copy update

* fix: copy change

* fix: make nf fields optional

* fix: info url checkbox value

* fix: error message position

* fix: leftover
  • Loading branch information
xstelea authored Nov 28, 2023
1 parent a35e729 commit 219eb62
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
18 changes: 12 additions & 6 deletions apps/console/src/components/Form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@
/>
{:else if item.formItemType === 'inputWithCheckbox'}
<div class="with-checkbox">
<Input
{disabled}
placeholder={item.placeholder}
bind:value={$state[item.key]}
schema={item.schema}
/>
<div class="input">
<Input
{disabled}
placeholder={item.placeholder}
bind:value={$state[item.key]}
schema={item.schema}
/>
</div>
<Checkbox
checked={checkboxValue(item.checkboxKey)}
{disabled}
Expand Down Expand Up @@ -144,4 +146,8 @@
align-items: center;
gap: var(--spacing-lg);
}
.input {
width: 100%;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
label: 'Info URL',
placeholder: 'Enter info URL',
formItemType: 'inputWithCheckbox',
checkboxKey: 'iconUrlLocked',
checkboxKey: 'infoUrlLocked',
checkboxLabel: 'Lock',
schema: z.string().startsWith('https://', {
message: 'Must provide URL that starts with https://'
Expand Down Expand Up @@ -385,15 +385,15 @@
},
{
key: 'nft_data_setter',
label: 'nft_data_setter',
label: 'non_fungible_data_updater',
placeholder: 'Select auth rule',
formItemType: 'select',
items: authRuleSelectItems,
showCondition: nonFungibleOnlyConditionFn
},
{
key: 'nft_data_setter_updater',
label: 'nft_data_setter_updater',
label: 'non_fungible_data_updater_updater',
placeholder: 'Select auth rule',
formItemType: 'select',
items: authRuleSelectItems,
Expand Down
14 changes: 5 additions & 9 deletions apps/console/src/pages/navbar-pages/create-token/Nft.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,23 @@
label: 'Description',
placeholder: 'Enter NFT description (truncated after 256 characters)',
formItemType: 'textarea',
rows: 2,
schema: string().min(1, { message: 'description required' })
rows: 2
},
{
key: 'key_image_url',
label: 'Key image URL',
placeholder: 'Enter key image URL',
formItemType: 'input',
schema: string()
.min(1, { message: 'image key URL required' })
.startsWith('https://', {
message: 'URL must start with https://'
})
formItemType: 'input'
}
]
$: {
const values = $state
const isInvalid = formItems.some((item) => {
const value = values[item.key as keyof NftData]
const invalid = item.schema!.safeParse(value).success === false
const invalid = item.schema
? item.schema.safeParse(value).success === false
: false
return invalid
})
dispatch('change', {
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/src/dev-console/form/Input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
</script>

<div class="content">
<slot name="before" />
<input {placeholder} class:disabled class:error on:input bind:value />
<slot name="after" />
</div>

{#if schema}
Expand All @@ -62,6 +60,7 @@
width: 100%;
line-height: 1.5rem;
display: flex;
flex-direction: column;
}
input {
Expand Down
13 changes: 7 additions & 6 deletions packages/ui/src/dev-console/form/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@
let selectItemsYCoord = 0
$: {
computePosition(element!, dropdownElement, {
placement: 'bottom',
middleware: [flip()]
}).then(({ y }) => {
selectItemsYCoord = y
})
if (element && dropdownElement)
computePosition(element!, dropdownElement, {
placement: 'bottom',
middleware: [flip()]
}).then(({ y }) => {
selectItemsYCoord = y
})
}
</script>

Expand Down

0 comments on commit 219eb62

Please sign in to comment.