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): changed colors and sizes in placeholders and nav #1546

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions .changeset/wicked-kids-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alfalab/core-components-gallery': minor
---

Изменены цвета и размеры навигации и заглушек при загрузке
1 change: 1 addition & 0 deletions packages/gallery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@alfalab/core-components-base-modal": "^5.8.8",
"@alfalab/core-components-icon-button": "^6.11.6",
"@alfalab/core-components-mq": "^4.4.1",
"@alfalab/core-components-spinner": "^4.0.3",
"@alfalab/core-components-tooltip": "^7.8.4",
"@alfalab/core-components-typography": "^4.11.3",
"@alfalab/hooks": "^1.13.1",
Expand Down
5 changes: 4 additions & 1 deletion packages/gallery/src/components/buttons/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
}
}

/* TODO: применять static цвет через prop IconButton'а */
.iconButton {
& path {
color: var(--color-static-neutral-100);
}

&:hover path {
color: var(--color-static-neutral-100-hover);
}
Expand Down
16 changes: 1 addition & 15 deletions packages/gallery/src/components/buttons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const Fullscreen: FC<Props> = ({ buttonRef, ...restProps }) => (
{...restProps}
ref={buttonRef}
icon={ArrowsOutwardMIcon}
colors='inverted'
aria-label='Открыть в полноэкранном режиме'
className={styles.iconButton}
/>
Expand All @@ -43,7 +42,6 @@ export const BackArrow: FC<Props> = ({ buttonRef, ...restProps }) => (
{...restProps}
ref={buttonRef}
icon={ArrowLeftMIcon}
colors='inverted'
aria-label='Вернуться назад'
className={styles.iconButton}
/>
Expand All @@ -54,7 +52,6 @@ export const Play: FC<Props> = ({ buttonRef, className, ...restProps }) => (
{...restProps}
ref={buttonRef}
icon={PlayCompactMIcon}
colors='inverted'
aria-label='Проиграть видео'
className={cn(styles.iconButton, className)}
/>
Expand All @@ -65,7 +62,6 @@ export const Pause: FC<Props> = ({ buttonRef, className, ...restProps }) => (
{...restProps}
ref={buttonRef}
icon={PauseCompactMIcon}
colors='inverted'
aria-label='Поставить паузу на видео'
className={cn(styles.iconButton, className)}
/>
Expand All @@ -82,7 +78,6 @@ export const ExitFullscreen: FC<Props> = ({ buttonRef, ...restProps }) => (
{...restProps}
ref={buttonRef}
icon={ArrowsInwardMIcon}
colors='inverted'
aria-label='Выйти из полноэкранного режима'
className={styles.iconButton}
/>
Expand All @@ -101,7 +96,6 @@ export const MuteVideo: FC<Props> = ({ buttonRef, className, ...restProps }) =>
{...restProps}
ref={buttonRef}
icon={SoundMIcon}
colors='inverted'
aria-label='Выключить звук'
className={styles.iconButton}
/>
Expand All @@ -120,7 +114,6 @@ export const UnmuteVideo: FC<Props> = ({ buttonRef, className, ...restProps }) =
{...restProps}
ref={buttonRef}
icon={SoundCrossMIcon}
colors='inverted'
aria-label='Включить звук'
className={styles.iconButton}
/>
Expand All @@ -137,19 +130,12 @@ export const Download: FC<Props> = (props) => (
<IconButton
{...props}
icon={PointerDownMIcon}
colors='inverted'
aria-label='Скачать'
className={styles.iconButton}
/>
</TooltipDesktop>
);

export const Exit: FC<Props> = (props) => (
<IconButton
{...props}
icon={CrossMIcon}
colors='inverted'
aria-label='Закрыть'
className={styles.iconButton}
/>
<IconButton {...props} icon={CrossMIcon} aria-label='Закрыть' className={styles.iconButton} />
);
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
user-select: none;

&.mobile {
width: 36px;
width: 46px;
height: 46px;
border-radius: var(--border-radius-8);
}
Expand Down
11 changes: 1 addition & 10 deletions packages/gallery/src/components/image-viewer/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ export const ImageViewer: FC = () => {
getCurrentImage,
} = useContext(GalleryContext);

const {
handleLoad,
handleLoadError,
handleWrapperClick,
isMobile,
rightArrowRef,
leftArrowRef,
} = useHandleImageViewer();
const { handleWrapperClick, isMobile, rightArrowRef, leftArrowRef } = useHandleImageViewer();

const [leftArrowFocused] = useFocus(leftArrowRef, 'keyboard');
const [rightArrowFocused] = useFocus(rightArrowRef, 'keyboard');
Expand Down Expand Up @@ -176,8 +169,6 @@ export const ImageViewer: FC = () => {
index={index}
imageAspectRatio={imageAspectRatio}
slideVisible={slideVisible}
handleLoad={handleLoad}
Copy link
Collaborator

@fulcanellee fulcanellee Jan 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это так и должно быть? не совсем понял

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это так и должно быть? не совсем понял

там хук написали, я в компоненте просто это из хука получаю. не вижу смысла прокидывать пропс

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleLoadError={handleLoadError}
/>
)}
</SwiperSlide>
Expand Down
11 changes: 8 additions & 3 deletions packages/gallery/src/components/image-viewer/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@
}

.slideLoading {
background-color: var(--color-static-neutral-100-inverted);
background-color: var(--color-static-neutral-translucent-100-inverted);
border-radius: var(--border-radius-8);
}

.spinner {
position: absolute;
color: var(--color-static-neutral-translucent-1300-inverted);
}

.image {
width: 0;
height: 0;
Expand Down Expand Up @@ -121,8 +126,8 @@
display: flex;
justify-content: center;
align-items: center;
width: 400px;
height: 300px;
width: 100%;
height: 100%;
border-radius: var(--border-radius-8);
background-color: var(--color-static-neutral-300-inverted);
}
Expand Down
4 changes: 1 addition & 3 deletions packages/gallery/src/components/image-viewer/single.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const Single: FC = () => {
const { fullScreen, currentSlideIndex, getCurrentImage, getCurrentImageMeta } =
useContext(GalleryContext);

const { handleLoad, handleLoadError, handleWrapperClick, isMobile } = useHandleImageViewer();
const { handleWrapperClick, isMobile } = useHandleImageViewer();

const wrapperRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -57,8 +57,6 @@ export const Single: FC = () => {
index={0}
imageAspectRatio={imageAspectRatio}
slideVisible={true}
handleLoad={handleLoad}
handleLoadError={handleLoadError}
/>
</div>
)}
Expand Down
36 changes: 9 additions & 27 deletions packages/gallery/src/components/image-viewer/slide.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, { FC, ReactNode, SyntheticEvent, useContext } from 'react';
import React, { FC, ReactNode, useContext } from 'react';
import cn from 'classnames';

import { Spinner } from '@alfalab/core-components-spinner';
import { Text } from '@alfalab/core-components-typography';

import { GalleryContext } from '../../context';
import { GalleryImage, ImageMeta } from '../../types';
import { getImageAlt, isSmallImage, isVideo, TestIds } from '../../utils';

import { useHandleImageViewer } from './hooks';
import { NoImagePaths } from './paths';
import { Video } from './video';

Expand All @@ -15,19 +17,12 @@ import styles from './index.module.css';
type SlideInnerProps = {
active: boolean;
broken: boolean;
withPlaceholder: boolean;
loading: boolean;
children: ReactNode;
isVideoView?: boolean;
};

const SlideInner: FC<SlideInnerProps> = ({
children,
broken,
loading,
withPlaceholder,
isVideoView,
}) => {
const SlideInner: FC<SlideInnerProps> = ({ children, broken, loading, isVideoView }) => {
const content = broken ? (
<div className={styles.brokenImgWrapper}>
<div className={styles.brokenImgIcon}>
Expand Down Expand Up @@ -59,7 +54,8 @@ const SlideInner: FC<SlideInnerProps> = ({

return (
<div className={cn(styles.slide, { [styles.slideLoading]: loading })}>
{withPlaceholder ? <div className={styles.placeholder}>{content}</div> : content}
{broken ? <div className={styles.placeholder}>{content}</div> : content}
<Spinner className={styles.spinner} preset={48} visible={loading} />
</div>
);
};
Expand All @@ -73,8 +69,6 @@ type SlideProps = {
index: number;
containerHeight: number;
slideVisible: boolean;
handleLoad: (event: SyntheticEvent<HTMLImageElement>, index: number) => void;
handleLoadError: (index: number) => void;
};

export const Slide: FC<SlideProps> = ({
Expand All @@ -86,10 +80,9 @@ export const Slide: FC<SlideProps> = ({
index,
containerHeight,
slideVisible,
handleLoad,
handleLoadError,
}) => {
const { view } = useContext(GalleryContext);
const { handleLoad, handleLoadError } = useHandleImageViewer();

const broken = Boolean(meta?.broken);
const small = isSmallImage(meta);
Expand All @@ -98,25 +91,14 @@ export const Slide: FC<SlideProps> = ({

if (isVideo(image.src)) {
return (
<SlideInner
isVideoView={true}
active={isActive}
broken={broken}
withPlaceholder={broken}
loading={!meta}
>
<SlideInner isVideoView={true} active={isActive} broken={broken} loading={!meta}>
<Video url={image.src} index={index} isActive={isActive} />
</SlideInner>
);
}

return (
<SlideInner
active={isActive}
broken={broken}
loading={!meta}
withPlaceholder={small || broken}
>
<SlideInner active={isActive} broken={broken} loading={!meta}>
<img
src={image.src}
alt={getImageAlt(image, index)}
Expand Down
4 changes: 4 additions & 0 deletions packages/gallery/src/docs/Component.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export const gallery: Story = {
name: 'Маленькое изображение.jpg',
src: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTUwIiBoZWlnaHQ9IjE1MCIgdmlld0JveD0iMCAwIDE1MCAxNTAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIxNTAiIGhlaWdodD0iMTUwIiBmaWxsPSIjNDU0Nzc4Ii8+Cjwvc3ZnPgo=',
},
{
name: 'Alfa promo.m3u8',
src: 'https://alfavideo.servicecdn.ru/videos/101064_31s0hnwZaamhbwE/master.m3u8',
},
{
name: 'Битое изображение.jpg',
src: 'data:image/svg+xml;base64,',
Expand Down
2 changes: 1 addition & 1 deletion packages/gallery/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const TestIds = {
UNMUTE_BUTTON: 'unmute-button',
};

export const PREVIEW_WIDTH_MOBILE = 36;
export const PREVIEW_WIDTH_MOBILE = 46;
export const PREVIEW_HEIGHT_MOBILE = 46;

export const PREVIEW_WIDTH_DESKTOP = 56;
Expand Down
2 changes: 2 additions & 0 deletions packages/gallery/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
"@alfalab/core-components-*": ["../*/src"],
"@alfalab/core-components-button/*": ["../button/src/*"],
"@alfalab/core-components-tooltip/*": ["../tooltip/src/*"],
"@alfalab/core-components-spinner/*": ["../spinner/src/*"],
"@alfalab/core-components-icon-view/*": ["../icon-view/src/*"],
"@alfalab/core-components-mq/*": ["../mq/src/*"]
}
},
"references": [
{ "path": "../typography" },
{ "path": "../spinner" },
{ "path": "../tooltip" },
{ "path": "../icon-button" },
{ "path": "../typography" },
Expand Down
Loading