From b1e2532985cb37dbe72b2ffb3d393812ad42f514 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sun, 10 Oct 2021 05:39:40 -0700 Subject: [PATCH] Add scroll buttons to horizontal menu --- .../scrollingmenu/ScrollingMenu.tsx | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/src/components/scrollingmenu/ScrollingMenu.tsx b/src/components/scrollingmenu/ScrollingMenu.tsx index 59d3113..115892c 100644 --- a/src/components/scrollingmenu/ScrollingMenu.tsx +++ b/src/components/scrollingmenu/ScrollingMenu.tsx @@ -1,9 +1,10 @@ -import React from 'react'; +import React, { useRef } from 'react'; import path from 'path'; import settings from 'electron-settings'; import styled from 'styled-components'; +import { ButtonGroup, ButtonToolbar, FlexboxGrid, Icon } from 'rsuite'; import Card from '../card/Card'; -import { SectionTitleWrapper, SectionTitle } from '../shared/styled'; +import { SectionTitleWrapper, SectionTitle, StyledIconButton } from '../shared/styled'; import { getImageCachePath } from '../../shared/utils'; const ScrollMenuContainer = styled.div` @@ -14,19 +15,56 @@ const ScrollMenuContainer = styled.div` ::-webkit-scrollbar { height: 10px; } + + scroll-behavior: smooth; `; const ScrollingMenu = ({ cardTitle, cardSubtitle, data, title, onClickTitle, type }: any) => { const cacheImages = Boolean(settings.getSync('cacheImages')); const cachePath = path.join(getImageCachePath(), '/'); + const scrollContainerRef = useRef(); + const gridCardSize = Number(settings.getSync('gridCardSize')); return ( <> - {title} + + + { + console.log(e); + if (e.key === ' ' || e.key === 'Enter') { + onClickTitle(); + } + }} + > + {title} + + + + + + } + onClick={() => { + scrollContainerRef.current.scrollLeft -= gridCardSize * 5; + }} + /> + } + onClick={() => { + scrollContainerRef.current.scrollLeft += gridCardSize * 5; + }} + /> + + + + - + {data.map((item: any) => (