mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Added unstyled property to image uploads AdminX
refs. https://github.com/TryGhost/Team/issues/3354
This commit is contained in:
parent
9faf2cafbe
commit
f05b6a6037
3 changed files with 50 additions and 18 deletions
|
@ -8,6 +8,7 @@ interface ImageUploadProps {
|
||||||
width?: string;
|
width?: string;
|
||||||
height?: string;
|
height?: string;
|
||||||
imageURL?: string;
|
imageURL?: string;
|
||||||
|
unstyled?: boolean;
|
||||||
imageClassName?: string;
|
imageClassName?: string;
|
||||||
fileUploadClassName?: string;
|
fileUploadClassName?: string;
|
||||||
deleteButtonClassName?: string;
|
deleteButtonClassName?: string;
|
||||||
|
@ -22,18 +23,26 @@ const ImageUpload: React.FC<ImageUploadProps> = ({
|
||||||
width,
|
width,
|
||||||
height = '120px',
|
height = '120px',
|
||||||
imageURL,
|
imageURL,
|
||||||
imageClassName = 'group relative bg-cover',
|
imageClassName,
|
||||||
fileUploadClassName = 'flex cursor-pointer items-center justify-center rounded border border-grey-100 bg-grey-75 p-3 text-sm font-semibold text-grey-800 hover:text-black',
|
fileUploadClassName,
|
||||||
deleteButtonClassName = 'invisible absolute right-4 top-4 flex h-8 w-8 cursor-pointer items-center justify-center rounded bg-[rgba(0,0,0,0.75)] text-white hover:bg-black group-hover:!visible',
|
deleteButtonClassName,
|
||||||
deleteButtonContent = <Icon color='white' name='trash' size='sm' />,
|
deleteButtonContent,
|
||||||
|
unstyled = false,
|
||||||
onUpload,
|
onUpload,
|
||||||
onDelete
|
onDelete
|
||||||
}) => {
|
}) => {
|
||||||
|
if (!unstyled) {
|
||||||
|
imageClassName = imageClassName || 'group relative bg-cover';
|
||||||
|
fileUploadClassName = fileUploadClassName || 'flex cursor-pointer items-center justify-center rounded border border-grey-100 bg-grey-75 p-3 text-sm font-semibold text-grey-800 hover:text-black';
|
||||||
|
deleteButtonClassName = deleteButtonClassName || 'invisible absolute right-4 top-4 flex h-8 w-8 cursor-pointer items-center justify-center rounded bg-[rgba(0,0,0,0.75)] text-white hover:bg-black group-hover:!visible';
|
||||||
|
deleteButtonContent = deleteButtonContent || <Icon color='white' name='trash' size='sm' />;
|
||||||
|
}
|
||||||
|
|
||||||
if (imageURL) {
|
if (imageURL) {
|
||||||
return (
|
return (
|
||||||
<div className={imageClassName} style={{
|
<div className={imageClassName} style={{
|
||||||
width: width,
|
width: (unstyled ? '' : width),
|
||||||
height: height,
|
height: (unstyled ? '' : height),
|
||||||
backgroundImage: `url(${imageURL})`
|
backgroundImage: `url(${imageURL})`
|
||||||
}}>
|
}}>
|
||||||
<button className={deleteButtonClassName} type='button' onClick={onDelete}>
|
<button className={deleteButtonClassName} type='button' onClick={onDelete}>
|
||||||
|
@ -45,8 +54,8 @@ const ImageUpload: React.FC<ImageUploadProps> = ({
|
||||||
return (
|
return (
|
||||||
<FileUpload className={fileUploadClassName} id={id} style={
|
<FileUpload className={fileUploadClassName} id={id} style={
|
||||||
{
|
{
|
||||||
width: width,
|
width: (unstyled ? '' : width),
|
||||||
height: height
|
height: (unstyled ? '' : height)
|
||||||
}
|
}
|
||||||
} onUpload={onUpload}>
|
} onUpload={onUpload}>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
@ -629,6 +629,7 @@ const UserDetailModal:React.FC<UserDetailModalProps> = ({user, updateUser}) => {
|
||||||
id='cover-image'
|
id='cover-image'
|
||||||
imageClassName='absolute inset-0 bg-cover group bg-center rounded-t overflow-hidden'
|
imageClassName='absolute inset-0 bg-cover group bg-center rounded-t overflow-hidden'
|
||||||
imageURL={userData.cover_image || ''}
|
imageURL={userData.cover_image || ''}
|
||||||
|
unstyled={true}
|
||||||
onDelete={() => {
|
onDelete={() => {
|
||||||
handleImageDelete('cover_image');
|
handleImageDelete('cover_image');
|
||||||
}}
|
}}
|
||||||
|
@ -640,14 +641,14 @@ const UserDetailModal:React.FC<UserDetailModalProps> = ({user, updateUser}) => {
|
||||||
<Menu items={menuItems} position='left' trigger={<UserMenuTrigger />}></Menu>
|
<Menu items={menuItems} position='left' trigger={<UserMenuTrigger />}></Menu>
|
||||||
</div>
|
</div>
|
||||||
<div className='relative flex items-center gap-4 px-12 pb-12 pt-60'>
|
<div className='relative flex items-center gap-4 px-12 pb-12 pt-60'>
|
||||||
|
|
||||||
<ImageUpload
|
<ImageUpload
|
||||||
deleteButtonClassName='invisible absolute -right-2 -top-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-full bg-[rgba(0,0,0,0.75)] text-white hover:bg-black group-hover:!visible'
|
deleteButtonClassName='invisible absolute -right-2 -top-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-full bg-[rgba(0,0,0,0.75)] text-white hover:bg-black group-hover:!visible'
|
||||||
fileUploadClassName='rounded-full bg-black flex items-center justify-center opacity-80 transition hover:opacity-100 -ml-2 cursor-pointer'
|
deleteButtonContent={<Icon color='white' name='trash' size='sm' />}
|
||||||
height='80px'
|
fileUploadClassName='rounded-full bg-black flex items-center justify-center opacity-80 transition hover:opacity-100 -ml-2 cursor-pointer h-[80px] w-[80px]'
|
||||||
id='avatar'
|
id='avatar'
|
||||||
imageClassName='relative rounded-full group bg-cover bg-center -ml-2'
|
imageClassName='relative rounded-full group bg-cover bg-center -ml-2 h-[80px] w-[80px]'
|
||||||
imageURL={userData.profile_image}
|
imageURL={userData.profile_image}
|
||||||
|
unstyled={true}
|
||||||
width='80px'
|
width='80px'
|
||||||
onDelete={() => {
|
onDelete={() => {
|
||||||
handleImageDelete('profile_image');
|
handleImageDelete('profile_image');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Button from '../../../../admin-x-ds/global/Button';
|
|
||||||
import Heading from '../../../../admin-x-ds/global/Heading';
|
import Heading from '../../../../admin-x-ds/global/Heading';
|
||||||
import Hint from '../../../../admin-x-ds/global/Hint';
|
import Hint from '../../../../admin-x-ds/global/Hint';
|
||||||
|
import ImageUpload from '../../../../admin-x-ds/global/ImageUpload';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import SettingGroupContent from '../../../../admin-x-ds/settings/SettingGroupContent';
|
import SettingGroupContent from '../../../../admin-x-ds/settings/SettingGroupContent';
|
||||||
import TextField from '../../../../admin-x-ds/global/TextField';
|
import TextField from '../../../../admin-x-ds/global/TextField';
|
||||||
|
@ -40,16 +40,38 @@ const BrandSettings: React.FC = () => {
|
||||||
<Heading level={6}>Publication icon</Heading>
|
<Heading level={6}>Publication icon</Heading>
|
||||||
<div className='mt-2 flex gap-3'>
|
<div className='mt-2 flex gap-3'>
|
||||||
<Hint className='mr-5'>A square, social icon, at least 60x60px</Hint>
|
<Hint className='mr-5'>A square, social icon, at least 60x60px</Hint>
|
||||||
<Button color='grey' label='Upload icon' />
|
<ImageUpload
|
||||||
|
height='36px'
|
||||||
|
id='logo'
|
||||||
|
width='150px'
|
||||||
|
onDelete={() => {}}
|
||||||
|
onUpload={() => {}}
|
||||||
|
>
|
||||||
|
Upload icon
|
||||||
|
</ImageUpload>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Heading level={6}>Publication logo</Heading>
|
<Heading className='mb-2' level={6}>Publication logo</Heading>
|
||||||
<Button className='mt-2' color='grey' fullWidth={true} label='Upload logo' />
|
<ImageUpload
|
||||||
|
height='80px'
|
||||||
|
id='logo'
|
||||||
|
onDelete={() => {}}
|
||||||
|
onUpload={() => {}}
|
||||||
|
>
|
||||||
|
Upload logo
|
||||||
|
</ImageUpload>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Heading level={6}>Publication cover</Heading>
|
<Heading className='mb-2' level={6}>Publication cover</Heading>
|
||||||
<Button className='mt-2' color='grey' fullWidth={true} label='Upload cover' />
|
<ImageUpload
|
||||||
|
height='140px'
|
||||||
|
id='cover'
|
||||||
|
onDelete={() => {}}
|
||||||
|
onUpload={() => {}}
|
||||||
|
>
|
||||||
|
Upload cover
|
||||||
|
</ImageUpload>
|
||||||
</div>
|
</div>
|
||||||
</SettingGroupContent>
|
</SettingGroupContent>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue