From fffa23a9e36e2682a562b7aa4b3b4a2c5b18e5ee Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 28 Oct 2021 17:25:25 +0200 Subject: [PATCH] add scroll functionality --- libs/remix-ui/tabs/src/lib/remix-ui-tabs.css | 21 +++++++++++++++++--- libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx | 19 ++++++++++++------ package.json | 2 +- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.css b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.css index 08462647ec..bd49390eb2 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.css +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.css @@ -40,9 +40,24 @@ border-top-left-radius: 2px; border-top-right-radius: 2px; } -.editor-f1 { +.tab-scroll { + overflow-x: auto; + overflow-y: hidden; + white-space: nowrap; + width: 95%; +} +.left-icon { + width: 5%; height: 49px; } -.editor-zoom { - height: 49px; + +/* Hide scrollbar for Chrome, Safari and Opera */ +.tab-scroll::-webkit-scrollbar { + display: none; +} + + /* Hide scrollbar for IE, Edge and Firefox */ +.tab-scroll { + -ms-overflow-style: none; /* IE and Edge */ + scrollbar-width: none; /* Firefox */ } diff --git a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx index 0c2980116b..b187fb382c 100644 --- a/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx +++ b/libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx @@ -21,12 +21,19 @@ export interface TabsUIApi { export const TabsUI = (props: TabsUIProps) => { const [selectedIndex, setSelectedIndex] = useState(-1) const currentIndexRef = useRef(-1) + const tabsRef = useRef({}) + + useEffect(() => { + if (props.tabs[selectedIndex]) { + tabsRef.current[selectedIndex].scrollIntoView({ behavior: 'smooth', block: 'center' }) + } + }, [selectedIndex]) const renderTab = (tab, index) => { const classNameImg = 'my-1 mr-1 text-dark ' + tab.iconClass const classNameTab = 'nav-item nav-link tab' + (index === selectedIndex ? ' active' : '') return ( -
+
{ tabsRef.current[index] = el }} className={classNameTab} title={tab.tooltip}> {tab.icon ? () : ()} {tab.title} props.onClose(index)}> @@ -53,12 +60,12 @@ export const TabsUI = (props: TabsUIProps) => { return (
-
- props.onZoomOut()}> - props.onZoomIn()}> +
+ props.onZoomOut()}> + props.onZoomIn()}> +
- - { props.onSelect(index); setSelectedIndex(index); currentIndexRef.current = index }} > + { props.onSelect(index); setSelectedIndex(index); currentIndexRef.current = index }} > {props.tabs.map((tab, i) => {renderTab(tab, i)})} {props.tabs.map((tab) => )} diff --git a/package.json b/package.json index 593867260f..833e460dfd 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "nightwatch_local_editor": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/editor.spec.js --env=chrome", "nightwatch_local_compiler": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/compiler_api.test.js --env=chrome", "nightwatch_local_txListener": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/txListener.test.js --env=chrome", - "nightwatch_local_fileManager": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/fileManager_api.spec.js --env=chrome", + "nightwatch_local_fileManager": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/fileManager_api.spec.js --env=firefox", "nightwatch_local_runAndDeploy": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/runAndDeploy.js --env=chrome-runAndDeploy", "nightwatch_local_url": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/url.spec.js --env=chrome", "nightwatch_local_verticalIconscontextmenu": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/verticalIconsPanel.spec.js --env=chrome",