-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup UI for example captures edit mode
- Loading branch information
Showing
6 changed files
with
125 additions
and
42 deletions.
There are no files selected for viewing
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
34 changes: 34 additions & 0 deletions
34
...ils/deployment-details-form/section-example-captures/section-example-captures.module.scss
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,34 @@ | ||
@import 'design-system/variables/variables.scss'; | ||
@import 'design-system/variables/colors.scss'; | ||
@import 'design-system/variables/typography.scss'; | ||
|
||
.collection { | ||
display: grid; | ||
grid-template-columns: 1fr 1fr 1fr; | ||
gap: 16px; | ||
} | ||
|
||
.card { | ||
background-color: $color-primary-2-50; | ||
width: 100%; | ||
border: 1px solid $color-neutral-100; | ||
border-radius: 4px; | ||
box-sizing: border-box; | ||
position: relative; | ||
overflow: hidden; | ||
} | ||
|
||
.cardContent { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
img { | ||
width: 100%; | ||
height: 100%; | ||
object-fit: contain; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...ent-details/deployment-details-form/section-example-captures/section-example-captures.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,62 @@ | ||
import { DeploymentDetails } from 'data-services/models/deployment-details' | ||
import { FileInput } from 'design-system/components/file-input/file-input' | ||
import { FileInputAccept } from 'design-system/components/file-input/types' | ||
import { InputContent } from 'design-system/components/input/input' | ||
import { ReactNode, useEffect, useState } from 'react' | ||
import styles from './section-example-captures.module.scss' | ||
|
||
const IMAGE_CONFIG = { | ||
MAX_SIZE: 1024 * 1024, // 1MB | ||
NUM_IMAGES: 12, | ||
RATIO: 16 / 9, | ||
} | ||
|
||
export const SectionExampleCaptures = ({ | ||
deployment, | ||
}: { | ||
deployment: DeploymentDetails | ||
}) => { | ||
const [files, setFiles] = useState<File[]>([]) | ||
|
||
return ( | ||
<InputContent | ||
label="Example captures" | ||
description={`Upload a maximum of ${IMAGE_CONFIG.NUM_IMAGES} images. Valid formats are PNG, GIF and JPEG.`} | ||
> | ||
<div className={styles.collection}> | ||
{deployment.exampleCaptures.map((exampelCapture, index) => ( | ||
<Card key={index}> | ||
<img src={exampelCapture.src} /> | ||
</Card> | ||
))} | ||
{files.map((file, index) => ( | ||
<Card key={index}> | ||
<img src={URL.createObjectURL(file)} /> | ||
</Card> | ||
))} | ||
<Card> | ||
<FileInput | ||
accept={FileInputAccept.Images} | ||
label="Choose images" | ||
multiple | ||
name="example-captures" | ||
onChange={(newFiles) => { | ||
setFiles([...files, ...Array.from(newFiles ?? [])]) | ||
}} | ||
/> | ||
</Card> | ||
</div> | ||
</InputContent> | ||
) | ||
} | ||
|
||
const Card = ({ children }: { children: ReactNode }) => ( | ||
<div | ||
className={styles.card} | ||
style={{ | ||
paddingBottom: `${(1 / IMAGE_CONFIG.RATIO) * 100}%`, | ||
}} | ||
> | ||
<div className={styles.cardContent}>{children}</div> | ||
</div> | ||
) |
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