Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Gallery): add Gallery component #247

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
/src/components/StoreBadge @NikitaCG
/src/components/Stories @darkgenius
/src/components/ConfirmDialog @kseniya57
/src/components/Gallery @kseniya57
10 changes: 7 additions & 3 deletions src/components/FilePreview/FilePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface FilePreviewProps extends QAProps {

onClick?: React.MouseEventHandler<HTMLDivElement>;
actions?: FilePreviewActionProps[];
hideName?: boolean;
}

export function FilePreview({
Expand All @@ -63,6 +64,7 @@ export function FilePreview({
description,
onClick,
actions,
hideName,
}: FilePreviewProps) {
const id = useUniqId();

Expand Down Expand Up @@ -125,9 +127,11 @@ export function FilePreview({
<Icon className={cn('icon-svg')} data={FILE_ICON[type]} size={20} />
</div>
)}
<Text className={cn('name')} color="secondary" ellipsis title={file.name}>
{file.name}
</Text>
{!hideName && (
<Text className={cn('name')} color="secondary" ellipsis title={file.name}>
{file.name}
</Text>
)}
{Boolean(description) && (
<Text
className={cn('description')}
Expand Down
17 changes: 9 additions & 8 deletions src/components/FilePreview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ A component for displaying the file.
| className | `string` | | | Class name for the file container |
| onClick | `function` | | | Click handler for the file container |
| [actions](#actions) | `FilePreviewActionProps[]` | | `[]` | Click handler for the file container |
| hideName | `Boolean` | | | Hide the file name |

#### Actions

For a file, you can prescribe actions that will be visible when you hover over it.

| Property | Type | Required | Default | Description |
| ---------- | ------------------------------------------------------------------------------------ | -------- | ------- | ------------------------------ |
| id | `String` | | | Action id |
| icon | `String` | | | Action icon |
| title | `String` | | | Action hint on hover |
| onClick | `function` | | | Action click handler |
| href | `String` | | | Action button href |
| extraProps | `ButtonHTMLAttributes<HTMLButtonElement> \| AnchorHTMLAttributes<HTMLAnchorElement>` | | | Additional action button props |
| Property | Type | Required | Default | Description |
| ---------- | ----------------------------------------- | ---------------------------------------- | ------- | ------------------------------ |
| id | `String` | | | Action id |
| icon | `String` | | | Action icon |
| title | `String` | | | Action hint on hover |
| onClick | `function` | | | Action click handler |
| href | `String` | | | Action button href |
| extraProps | `ButtonHTMLAttributes<HTMLButtonElement>` | AnchorHTMLAttributes<HTMLAnchorElement>` | | Additional action button props |

```jsx

Expand Down
214 changes: 214 additions & 0 deletions src/components/Gallery/Gallery.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
@use '../variables';

$block: '.#{variables.$ns}gallery';
$filePreviewBlock: '.#{variables.$ns}file-preview';

#{$block} {
.g-modal__content-wrapper {
margin: 0;
}

&__content {
display: flex;
flex-direction: column;

width: calc(100vw - 264px);
height: calc(100vh - 56px);
}

&__header {
display: flex;
align-items: start;

padding: var(--g-spacing-2) var(--g-spacing-3) var(--g-spacing-2) var(--g-spacing-5);

> * {
flex: 1;
min-width: 0;
}
}

&__navigation {
display: flex;
gap: var(--g-spacing-2);
align-items: center;
justify-content: center;
}

&__actions {
display: flex;
gap: var(--g-spacing-1);
align-items: stretch;
justify-content: flex-end;
}

&__active-item-info {
align-self: stretch;
align-items: center;
display: flex;
}

&__body {
position: relative;

display: flex;
align-items: center;
justify-content: center;

flex: 1;
min-height: 0;

padding: 0 var(--g-spacing-2);
}

&__body-navigation-button {
position: absolute;
inset-block: 0 60px;
z-index: 2;

width: 200px;
max-width: 20%;
padding: 0;
margin: 0;

appearance: none;
cursor: pointer;

background-color: transparent;
border: none;
outline: none;

&_direction_left {
inset-inline-start: 0;
// cursor design is in progress
// cursor:
// url('./assets/arrow-left.svg') 2 2,
// default;
}

&_direction_right {
inset-inline-end: var(--g-spacing-5);
// cursor design is in progress
// cursor:
// url('./assets/arrow-right.svg') 2 2,
// default;
}
}

&__footer {
padding: var(--g-spacing-2) var(--g-spacing-5) var(--g-spacing-4) var(--g-spacing-5);
}

&__preview-list {
display: flex;
gap: var(--g-spacing-2);
align-items: stretch;
overflow: auto hidden;
-ms-overflow-style: none;
scrollbar-width: none;

&::-webkit-scrollbar {
display: none;
}
}

&__preview-list-item {
width: 48px;
min-width: 48px;
height: 48px;
border: 2px solid transparent;
border-radius: var(--g-border-radius-l);
padding: 0;
margin: 0;

appearance: none;
cursor: pointer;

background-color: transparent;
outline: none;
overflow: hidden;

&_selected {
border-color: var(--g-color-line-brand);
}
}

&_mode_full-screen {
overflow: hidden;

.g-modal__content-wrapper,
.g-modal__content {
border-radius: 0;
}

#{$block} {
&__content {
width: 100vw;
height: 100vh;
}

&__body {
padding: 0;
}

&__header {
position: absolute;
inset-block-start: 0;
inset-inline: 0;
z-index: 3;

opacity: 0;

&:hover {
opacity: 1;
}
}

&__footer {
position: absolute;
inset-inline: 0;
inset-block-end: 0;
z-index: 1;

opacity: 0;
background-color: rgba(0, 0, 0, 0.45);

&:hover {
opacity: 1;
}
}
}

.g-root_theme_light,
.g-root_theme_light-hc {
#{$block}__header {
background-color: var(--g-color-private-white-450);
}
}

.g-root_theme_dark,
.g-root_theme_dark-hc {
#{$block}__header {
background-color: var(--g-color-private-black-450);
}
}
}

#{$filePreviewBlock}[class] {
width: 100%;
height: 100%;
}

#{$filePreviewBlock}__card {
width: 100%;
min-width: 100%;
height: 100%;
padding: 0;
}

#{$filePreviewBlock}__image,
#{$filePreviewBlock}__icon {
width: 100%;
height: 100%;
}
}
Loading
Loading