diff --git a/net/web/src/carousel/Carousel.jsx b/net/web/src/carousel/Carousel.jsx index 15ca6837..718d6854 100644 --- a/net/web/src/carousel/Carousel.jsx +++ b/net/web/src/carousel/Carousel.jsx @@ -4,72 +4,10 @@ import { CarouselWrapper } from './Carousel.styled'; import { RightOutlined, LeftOutlined, CloseOutlined, PictureOutlined, FireOutlined } from '@ant-design/icons'; import ReactResizeDetector from 'react-resize-detector'; -export function Carousel({ pad, ready, error, items, itemRenderer, itemRemove }) { +export function Carousel({ pad, items, itemRenderer, itemRemove }) { const [slots, setSlots] = useState([]); - const [padClass, setPadClass] = useState(''); - const [carouselRef, setCarouselRef] = useState(false); - const [itemIndex, setItemIndex] = useState(0); - const [scrollLeft, setScrollLeft] = useState('hidden'); - const [scrollRight, setScrollRight] = useState('hidden'); - const FUDGE = 1; let carousel = useRef(); - let itemWidth = useRef(new Map()); - - useEffect(() => { - setScroll('smooth'); - setArrows(); - }, [itemIndex, items]); - - useEffect(() => { - setScroll('auto'); - }, [carouselRef]); - - const updateItemIndex = (val) => { - setItemIndex((i) => { - if (i + val < 0) { - return 0; - } - return i + val; - }) - } - - const onLeft = () => { - if (itemIndex > 0) { - updateItemIndex(-1); - } - } - - const onRight = () => { - if(itemIndex + 1 < items.length) { - updateItemIndex(+1); - } - } - - const setScroll = (behavior) => { - let pos = FUDGE; - for (let i = 0; i < itemIndex; i++) { - pos += itemWidth.current.get(i) + 32; - } - if (carousel.current) { - carousel.current.scrollTo({ top: 0, left: pos, behavior }); - } - } - - const setArrows = () => { - if (itemIndex == 0) { - setScrollLeft('hidden'); - } - else { - setScrollLeft('unset'); - } - if (itemIndex + 1 >= items.length) { - setScrollRight('hidden'); - } - else { - setScrollRight('unset'); - } - } const RemoveItem = ({ index }) => { if (itemRemove) { @@ -80,68 +18,31 @@ export function Carousel({ pad, ready, error, items, itemRenderer, itemRemove }) useEffect(() => { let assets = []; - if (ready) { - for (let i = 0; i < items.length; i++) { - assets.push(( - - {({ width, height }) => { - itemWidth.current.set(i, width); - return ( -
-
{ itemRenderer(items[i], i) }
- -
- ); - }} -
- )); - } - if (items.length > 0) { - assets.push(
 
) - } - if (itemIndex >= items.length) { - if (items.length > 0) { - setItemIndex(items.length - 1); - } - else { - setItemIndex(0); - } - } + for (let i = 0; i < items.length; i++) { + assets.push(( + + {({ width, height }) => { + return ( +
+
{ itemRenderer(items[i], i) }
+ +
+ ); + }} +
+ )); + } + if (items.length > 0) { + assets.push(
) } - setSlots(assets); - setScroll(); - setArrows(); - }, [ready, items]); - - const onRefSet = (r) => { - if (r != null) { - carousel.current = r; - setCarouselRef(true); - } - } + }, [items]); return ( - { error && ( -
- -
- )} - { !ready && !error && ( -
- -
- )} - { ready && !error && ( - <> - -
-
- - )} +
); } diff --git a/net/web/src/carousel/Carousel.styled.js b/net/web/src/carousel/Carousel.styled.js index 5c511b49..cd44cd1f 100644 --- a/net/web/src/carousel/Carousel.styled.js +++ b/net/web/src/carousel/Carousel.styled.js @@ -12,7 +12,7 @@ export const CarouselWrapper = styled.div` flex-direction: row; padding-left: 32px; width: 100%; - overflow: hidden; + overflow: auto; /* hide scrollbar for IE, Edge and Firefox */ -ms-overflow-style: none; @@ -105,7 +105,7 @@ export const CarouselWrapper = styled.div` .space { height: 128px; - padding-left: 100%; + padding-left: 32px; } .object { diff --git a/net/web/src/session/conversation/addTopic/AddTopic.jsx b/net/web/src/session/conversation/addTopic/AddTopic.jsx index 2a5a3bb9..6f87d910 100644 --- a/net/web/src/session/conversation/addTopic/AddTopic.jsx +++ b/net/web/src/session/conversation/addTopic/AddTopic.jsx @@ -55,7 +55,7 @@ export function AddTopic({ cardId, channelId }) { const renderItem = (item, index) => { if (item.image) { - return + return } if (item.audio) { return actions.setLabel(index, label)}/> @@ -95,7 +95,7 @@ export function AddTopic({ cardId, channelId }) { onSelectVideo(e)} style={{display: 'none'}}/> { state.assets.length > 0 && (
- +
)}
diff --git a/net/web/src/session/conversation/addTopic/AddTopic.styled.js b/net/web/src/session/conversation/addTopic/AddTopic.styled.js index e5ee989d..35a7dd9f 100644 --- a/net/web/src/session/conversation/addTopic/AddTopic.styled.js +++ b/net/web/src/session/conversation/addTopic/AddTopic.styled.js @@ -15,7 +15,9 @@ export const AddTopicWrapper = styled.div` } .assets { - padding-top: 8px; + margin-top: 8px; + height: 128px; + overflow: auto; } .buttons { diff --git a/net/web/src/session/conversation/addTopic/videoFile/VideoFile.jsx b/net/web/src/session/conversation/addTopic/videoFile/VideoFile.jsx index 4b306130..dfb4ae48 100644 --- a/net/web/src/session/conversation/addTopic/videoFile/VideoFile.jsx +++ b/net/web/src/session/conversation/addTopic/videoFile/VideoFile.jsx @@ -47,13 +47,13 @@ export function VideoFile({ url, onPosition }) { }}
-
-
+
+
onSeek(-1)}>
-
+
onSeek(1)}>
diff --git a/net/web/src/session/conversation/addTopic/videoFile/VideoFile.styled.js b/net/web/src/session/conversation/addTopic/videoFile/VideoFile.styled.js index 1126183f..84deeab6 100644 --- a/net/web/src/session/conversation/addTopic/videoFile/VideoFile.styled.js +++ b/net/web/src/session/conversation/addTopic/videoFile/VideoFile.styled.js @@ -11,19 +11,19 @@ export const VideoFileWrapper = styled.div` display: flex; align-items: center; - .arrows { + .seek { width: 100%; display: flex; flex-direction: row; align-items: center; - .left-arrow { + .left-seek { width: 50%; display: flex; justify-content: flex-begin; } - .right-arrow { + .right-seek { width: 50%; display: flex; justify-content: flex-end; diff --git a/net/web/src/session/conversation/topicItem/TopicItem.jsx b/net/web/src/session/conversation/topicItem/TopicItem.jsx index 5cec40ca..ca3164fb 100644 --- a/net/web/src/session/conversation/topicItem/TopicItem.jsx +++ b/net/web/src/session/conversation/topicItem/TopicItem.jsx @@ -6,7 +6,7 @@ import { AudioAsset } from './audioAsset/AudioAsset'; import { ImageAsset } from './imageAsset/ImageAsset'; import { Logo } from 'logo/Logo'; import { Space, Skeleton, Button, Modal, Input } from 'antd'; -import { ExclamationCircleOutlined, DeleteOutlined, EditOutlined } from '@ant-design/icons'; +import { ExclamationCircleOutlined, DeleteOutlined, EditOutlined, FireOutlined, PictureOutlined } from '@ant-design/icons'; import { Carousel } from 'carousel/Carousel'; export function TopicItem({ host, topic }) { @@ -116,9 +116,19 @@ export function TopicItem({ host, topic }) { )} { state.confirmed && (
- { state.assets.length > 0 && ( + { state.error && ( +
+ +
+ )} + { !state.error && !state.ready && ( +
+ +
+ )} + { !state.error && state.ready && state.assets.length > 0 && (
- +
)}
diff --git a/net/web/src/session/conversation/topicItem/TopicItem.styled.js b/net/web/src/session/conversation/topicItem/TopicItem.styled.js index df70771c..b8fcc3e4 100644 --- a/net/web/src/session/conversation/topicItem/TopicItem.styled.js +++ b/net/web/src/session/conversation/topicItem/TopicItem.styled.js @@ -77,6 +77,17 @@ export const TopicItemWrapper = styled.div` } } + .asset-placeholder { + width: 128px; + height: 128px; + display: flex; + align-items: center; + justify-content: center; + background-color: #eeeeee; + color: #888888; + margin-left: 72px; + } + .topic-assets { padding-top: 4px; }