Skip to content

Commit

Permalink
added banner to DAO home page
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Nov 7, 2024
1 parent b5d7a2b commit 919c133
Show file tree
Hide file tree
Showing 14 changed files with 320 additions and 163 deletions.
3 changes: 2 additions & 1 deletion packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@
"automaticallyAddNFTsTooltip": "Should NFTs sent to the DAO get added to the treasury?",
"automaticallyAddTokensTitle": "Automatically add tokens",
"automaticallyAddTokensTooltip": "Should tokens sent to the DAO get added to the treasury?",
"banner": "Banner",
"baseToken": "Base token",
"becomeSubDaoAdminInputLabel": "New parent DAO",
"blocksToPauseFor": "Blocks to pause for",
Expand Down Expand Up @@ -1510,7 +1511,7 @@
},
"upToDate": "Up to date",
"updateContractAdminActionDescription": "Update the CosmWasm level admin of a smart contract.",
"updateInfoActionDescription": "Update your DAO's name, image, and description.",
"updateInfoActionDescription": "Update your DAO's name, description, image, and banner.",
"updateMinterAllowanceDescription": "Allow an account to mint tokens, or remove the allowance.",
"updateMinterAllowanceExplanation": "This action is needed to allow an account to mint tokens.",
"updatePostDescription": "Update a post on the DAO's press.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const UploadNftMetadata: ActionComponent = ({
'metadata.properties.audio') as 'metadata.properties.audio'
}
register={register}
validation={[(v) => !v || validateUrlWithIpfs(v)]}
validation={[validateUrlWithIpfs]}
/>

<InputErrorMessage error={errors?.metadata?.properties?.audio} />
Expand All @@ -189,7 +189,7 @@ export const UploadNftMetadata: ActionComponent = ({
'metadata.properties.video') as 'metadata.properties.video'
}
register={register}
validation={[(v) => !v || validateUrlWithIpfs(v)]}
validation={[validateUrlWithIpfs]}
/>

<InputErrorMessage error={errors?.metadata?.properties?.video} />
Expand Down
176 changes: 100 additions & 76 deletions packages/stateful/actions/core/actions/UpdateInfo/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import {

import { LinkWrapper, Trans } from '../../../../components'

export type UpdateInfoData = ConfigV1Response | ConfigV2Response
export type UpdateInfoData = (ConfigV1Response | ConfigV2Response) & {
banner?: string | null
}

export const UpdateInfoComponent: ActionComponent<
undefined,
Expand All @@ -35,98 +37,120 @@ export const UpdateInfoComponent: ActionComponent<
const { t } = useTranslation()
const { register, watch, setValue } = useFormContext()

const banner = watch(fieldNamePrefix + 'banner')

const isNeutronForkDao =
context.type === ActionContextType.Dao &&
context.dao.chainId === ChainId.NeutronMainnet &&
isNeutronForkVersion(context.dao.coreVersion)

return (
<div className="flex flex-row flex-wrap items-center justify-center gap-4">
{!isNeutronForkDao &&
(isCreating ? (
<div className="flex flex-col gap-4 pl-2">
<ImageSelector
Trans={Trans}
error={errors?.image_url}
fieldName={fieldNamePrefix + 'image_url'}
register={register}
setValue={setValue}
watch={watch}
/>
<InputLabel name={t('form.selectAnImage')} />
</div>
) : (
<DaoImage
LinkWrapper={LinkWrapper}
className="ml-2"
coreAddress={address}
daoName={name}
imageUrl={data.image_url}
size="lg"
/>
))}

<div className="flex grow flex-col gap-2">
<div>
<TextInput
disabled={!isCreating}
error={errors?.name}
fieldName={fieldNamePrefix + 'name'}
placeholder={t('form.name')}
register={register}
validation={[validateRequired]}
/>
<InputErrorMessage error={errors?.name} />
</div>

<div>
<TextAreaInput
<>
{(isCreating || !!banner) && (
<div className="flex flex-col items-stretch gap-2">
<InputLabel name={t('form.banner')} />
<ImageSelector
Trans={Trans}
className="h-24"
disabled={!isCreating}
error={errors?.description}
fieldName={fieldNamePrefix + 'description'}
placeholder={t('form.description')}
error={errors?.banner}
fieldName={fieldNamePrefix + 'banner'}
register={register}
validation={[validateRequired]}
setValue={setValue}
style="banner"
watch={watch}
/>
<InputErrorMessage error={errors?.description} />
</div>
)}

<div className="flex flex-row flex-wrap items-center justify-center gap-4">
{!isNeutronForkDao && (
<div className="flex flex-row flex-wrap gap-2">
<FormSwitchCard
containerClassName="grow"
fieldName={fieldNamePrefix + 'automatically_add_cw20s'}
label={t('form.automaticallyAddTokensTitle')}
readOnly={!isCreating}
setValue={setValue}
sizing="sm"
tooltip={t('form.automaticallyAddTokensTooltip')}
tooltipIconSize="sm"
value={watch(fieldNamePrefix + 'automatically_add_cw20s')}
<div className="flex flex-col items-center gap-2 pl-2">
<InputLabel name={t('form.image')} />
{isCreating ? (
<ImageSelector
Trans={Trans}
error={errors?.image_url}
fieldName={fieldNamePrefix + 'image_url'}
register={register}
setValue={setValue}
style="avatar"
watch={watch}
/>
) : (
<DaoImage
LinkWrapper={LinkWrapper}
coreAddress={address}
daoName={name}
imageUrl={data.image_url}
size="lg"
/>
)}
</div>
)}

<div className="flex grow flex-col gap-2">
<div>
<TextInput
disabled={!isCreating}
error={errors?.name}
fieldName={fieldNamePrefix + 'name'}
placeholder={t('form.name')}
register={register}
validation={[validateRequired]}
/>
<InputErrorMessage error={errors?.name} />
</div>

<FormSwitchCard
containerClassName="grow"
fieldName={fieldNamePrefix + 'automatically_add_cw721s'}
label={t('form.automaticallyAddNFTsTitle')}
readOnly={!isCreating}
setValue={setValue}
sizing="sm"
tooltip={t('form.automaticallyAddNFTsTooltip')}
tooltipIconSize="sm"
value={watch(fieldNamePrefix + 'automatically_add_cw721s')}
<div>
<TextAreaInput
disabled={!isCreating}
error={errors?.description}
fieldName={fieldNamePrefix + 'description'}
placeholder={t('form.description')}
register={register}
validation={[validateRequired]}
/>
<InputErrorMessage error={errors?.description} />
</div>
)}

{!isCreating && (
<p className="text-xs italic text-text-tertiary">
{t('info.daoInfoWillRefresh', {
seconds: DAO_STATIC_PROPS_CACHE_SECONDS.toLocaleString(),
})}
</p>
)}
{!isNeutronForkDao && (
<div className="flex flex-row flex-wrap gap-2">
<FormSwitchCard
containerClassName="grow"
fieldName={fieldNamePrefix + 'automatically_add_cw20s'}
label={t('form.automaticallyAddTokensTitle')}
readOnly={!isCreating}
setValue={setValue}
sizing="sm"
tooltip={t('form.automaticallyAddTokensTooltip')}
tooltipIconSize="sm"
value={watch(fieldNamePrefix + 'automatically_add_cw20s')}
/>

<FormSwitchCard
containerClassName="grow"
fieldName={fieldNamePrefix + 'automatically_add_cw721s'}
label={t('form.automaticallyAddNFTsTitle')}
readOnly={!isCreating}
setValue={setValue}
sizing="sm"
tooltip={t('form.automaticallyAddNFTsTooltip')}
tooltipIconSize="sm"
value={watch(fieldNamePrefix + 'automatically_add_cw721s')}
/>
</div>
)}

{!isCreating && (
<p className="text-xs italic text-text-tertiary">
{t('info.daoInfoWillRefresh', {
seconds: DAO_STATIC_PROPS_CACHE_SECONDS.toLocaleString(),
})}
</p>
)}
</div>
</div>
</div>
</>
)
}
4 changes: 3 additions & 1 deletion packages/stateful/actions/core/actions/UpdateInfo/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# UpdateInfo

Update the name, description, image, and some other config for the DAO.
Update the name, description, image, banner, and some other config for the DAO.

## Bulk import format

Expand All @@ -19,6 +19,8 @@ guide](https://github.com/DA0-DA0/dao-dao-ui/wiki/Bulk-importing-actions).
"description": "<DESCRIPTION>",
// Optional. If unset, will be removed.
"image_url": "<IMAGE URL>",
// Optional. If unset, will be removed.
"banner": "<BANNER URL>",
"automatically_add_cw20s": <true | false>,
"automatically_add_cw721s": <true | false>,
// Only on v2 and above. Optional. If unset, will be removed.
Expand Down
Loading

0 comments on commit 919c133

Please sign in to comment.