scrollelement for Featured plugins

pull/5370/head
lianahus 2 years ago committed by Aniket
parent f7144b6155
commit f67bdcdab7
  1. 4
      libs/remix-ui/home-tab/src/lib/components/homeTabFeatured.tsx
  2. 140
      libs/remix-ui/home-tab/src/lib/components/homeTabFeaturedPlugins.tsx
  3. 1
      libs/remix-ui/home-tab/src/lib/components/homeTabLearn.tsx
  4. 3
      libs/remix-ui/home-tab/src/lib/components/homeTabScamAlert.tsx
  5. 2
      libs/remix-ui/home-tab/src/lib/components/homeTabTitle.tsx
  6. 26
      libs/remix-ui/home-tab/src/lib/components/pluginButton.tsx
  7. 17
      libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.css
  8. 37
      libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx
  9. 15
      yarn.lock

@ -8,9 +8,7 @@ function HomeTabFeatured () {
searchInput: '' searchInput: ''
}) })
useEffect(() => { useEffect(() => {
document.addEventListener("keyup", (e) => handleSearchKeyDown(e)) document.addEventListener("keyup", (e) => handleSearchKeyDown(e))
return () => { return () => {
document.removeEventListener("keyup", handleSearchKeyDown) document.removeEventListener("keyup", handleSearchKeyDown)
} }
@ -42,7 +40,7 @@ function HomeTabFeatured () {
} }
return ( return (
<div className="" id="hTFeaturedeSection"> <div className="pt-4" id="hTFeaturedeSection">
<label style={{fontSize: "1.2rem"}}>Featured</label> <label style={{fontSize: "1.2rem"}}>Featured</label>
<div className="border"></div> <div className="border"></div>
</div> </div>

@ -1,50 +1,120 @@
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-unused-vars */
import React, { useEffect, useState, useRef } from 'react' import React, { useEffect, useState, useRef } from 'react'
import PluginButton from './pluginButton'
import { ThemeContext, themes } from '../themeContext'
import Carousel from 'react-multi-carousel'
import 'react-multi-carousel/lib/styles.css'
import CustomNavButtons from './customNavButtons'
declare global {
interface Window {
_paq: any
}
}
const _paq = window._paq = window._paq || [] //eslint-disable-line
interface HomeTabFeaturedPluginsProps {
plugin: any
}
function HomeTabFeaturedPlugins () { function HomeTabFeaturedPlugins ({plugin}: HomeTabFeaturedPluginsProps) {
const [state, setState] = useState<{ const [state, setState] = useState<{
searchInput: string themeQuality: { filter: string, name: string },
showMediaPanel: 'none' | 'twitter' | 'medium'
}>({ }>({
searchInput: '' themeQuality: themes.light,
showMediaPanel: 'none'
}) })
useEffect(() => {
document.addEventListener("keyup", (e) => handleSearchKeyDown(e))
return () => {
document.removeEventListener("keyup", handleSearchKeyDown)
}
}, [])
const searchInputRef = useRef(null) const startSolidity = async () => {
const remiAudioEl = useRef(null) await plugin.appManager.activatePlugin(['solidity', 'udapp', 'solidityStaticAnalysis', 'solidityUnitTesting'])
plugin.verticalIcons.select('solidity')
const playRemi = async () => { _paq.push(['trackEvent', 'pluginManager', 'userActivate', 'solidity'])
remiAudioEl.current.play()
} }
const handleSearchKeyDown = (e: KeyboardEvent) => { const startStarkNet = async () => {
if (e.target !== searchInputRef.current) return await plugin.appManager.activatePlugin('starkNet_compiler')
if (e.key === "Enter") { plugin.verticalIcons.select('starkNet_compiler')
openLink() _paq.push(['trackEvent', 'pluginManager', 'userActivate', 'starkNet_compiler'])
setState(prevState => {
return { ...prevState, searchInput: '' }
})
searchInputRef.current.value = ""
}
} }
const startSolhint = async () => {
const openLink = (url = "") => { await plugin.appManager.activatePlugin(['solidity', 'solhint'])
if (url === "") { plugin.verticalIcons.select('solhint')
window.open("https://remix-ide.readthedocs.io/en/latest/search.html?q=" + state.searchInput + "&check_keywords=yes&area=default", '_blank') _paq.push(['trackEvent', 'pluginManager', 'userActivate', 'solhint'])
} else { }
window.open(url, '_blank') const startLearnEth = async () => {
} await plugin.appManager.activatePlugin(['solidity', 'LearnEth', 'solidityUnitTesting'])
plugin.verticalIcons.select('LearnEth')
_paq.push(['trackEvent', 'pluginManager', 'userActivate', 'learnEth'])
}
const startSourceVerify = async () => {
await plugin.appManager.activatePlugin(['solidity', 'sourcify'])
plugin.verticalIcons.select('sourcify')
_paq.push(['trackEvent', 'pluginManager', 'userActivate', 'sourcify'])
} }
const startPluginManager = async () => {
plugin.verticalIcons.select('pluginManager')
}
const responsive = {
desktop: {
breakpoint: { max: 3000, min: 1024 },
items: 4,
slidesToSlide: 3 // optional, default to 1.
},
tablet: {
breakpoint: { max: 1024, min: 464 },
items: 2,
slidesToSlide: 2 // optional, default to 1.
},
mobile: {
breakpoint: { max: 464, min: 0 },
items: 1,
slidesToSlide: 1 // optional, default to 1.
}
};
const CustomNavButtons = ({ next, previous, goToSlide, ...rest }) => {
const { carouselState: { currentSlide } } = rest;
return (
<div className="d-flex justify-content-end carousel-button-group">
<button className={currentSlide === 0 ? 'disable py-0 border btn' : 'py-0 border btn'} onClick={() => previous()}>
<i className="fas fa-angle-left"></i>
</button>
<button className="py-0 border btn" onClick={() => next()} >
<i className="fas fa-angle-right"></i>
</button>
</div>
);
};
return ( return (
<div className="" id="hTFeaturedPlugins"> <div className="w-100" id="hTFeaturedPlugins">
<label style={{fontSize: "1.2rem"}}>Featured Plugins</label> <label className="pl-2" style={{fontSize: "1.2rem"}}>Featured Plugins</label>
<div className="border"></div> <div className="w-100 d-flex flex-column">
<ThemeContext.Provider value={ state.themeQuality }>
<Carousel
customButtonGroup={<CustomNavButtons next={undefined} previous={undefined} goToSlide={undefined} />}
arrows={false}
swipeable={false}
draggable={true}
showDots={false}
responsive={responsive}
renderDotsOutside={false}
renderButtonGroupOutside={true}
ssr={true} // means to render carousel on server-side.
infinite={false}
keyBoardControl={true}
containerClass="carousel-container"
deviceType={"desktop"}
itemClass="carousel-item-padding-10-px"
>
<PluginButton imgPath="assets/img/solidityLogo.webp" envID="solidityLogo" envText="Solidity" description="Compile, test and analyse smart contract." remixMaintained={true} callback={() => startSolidity()} />
<PluginButton imgPath="assets/img/starkNetLogo.webp" envID="starkNetLogo" envText="StarkNet" description="Compile and deploy contracts with Cairo, a native language for StarkNet." l2={true} callback={() => startStarkNet()} />
<PluginButton imgPath="assets/img/solhintLogo.webp" envID="solhintLogo" envText="Solhint linter" description="Solhint is an open source project for linting Solidity code." callback={() => startSolhint()} />
<PluginButton imgPath="assets/img/sourcifyNewLogo.webp" envID="sourcifyLogo" envText="Sourcify" description="Solidity contract and metadata verification service." callback={() => startSourceVerify()} />
<PluginButton imgPath="assets/img/moreLogo.webp" envID="moreLogo" envText="Plugin Manager" description="Discover more plugins." callback={startPluginManager} />
</Carousel>
</ThemeContext.Provider>
</div>
</div> </div>
) )
} }

@ -68,7 +68,6 @@ function HomeTabLearn ({plugin}: HomeTabLearnProps) {
</div>} </div>}
</button> </button>
</div> </div>
<br/>
</div> </div>
) )
} }

@ -5,7 +5,7 @@ function HomeTabScamAlert () {
return ( return (
<div className="" id="hTScamAlertSection"> <div className="" id="hTScamAlertSection">
<label className="pl-2 text-danger" style={{fontSize: "1.2rem"}}>Scam Alert</label> <label className="pl-2 text-danger" style={{fontSize: "1.2rem"}}>Scam Alert</label>
<div className="ml-2 align-self-end mb-2 d-flex flex-column border border-danger"> <div className="py-2 ml-2 align-self-end mb-2 d-flex flex-column border border-danger">
<span className="pl-4 mt-2"> <span className="pl-4 mt-2">
<i className="pr-2 text-danger fas fa-exclamation-triangle"></i> <i className="pr-2 text-danger fas fa-exclamation-triangle"></i>
<b>Scam Alerts:</b> <b>Scam Alerts:</b>
@ -21,7 +21,6 @@ function HomeTabScamAlert () {
Additional safety tips: &nbsp;<a className="remixui_home_text" target="__blank" href="https://remix-ide.readthedocs.io/en/latest/security.html">here</a> Additional safety tips: &nbsp;<a className="remixui_home_text" target="__blank" href="https://remix-ide.readthedocs.io/en/latest/security.html">here</a>
</span> </span>
</div> </div>
<br/>
</div> </div>
) )
} }

@ -53,7 +53,7 @@ function HomeTabTitle () {
></audio> ></audio>
</div> </div>
<div className="d-flex justify-content-between"> <div className="d-flex justify-content-between">
<span className="h-80" style={ { fontSize: 'xx-large', fontFamily: "Noah" } }>Remix</span> <span className="h-80" style={ { fontSize: 'x-large', fontFamily: "Noah" } }>Remix</span>
<span> <span>
<button <button
onClick={ ()=> openLink("https://www.youtube.com/channel/UCjTUPyFEr2xDGN6Cg8nKDaA")} onClick={ ()=> openLink("https://www.youtube.com/channel/UCjTUPyFEr2xDGN6Cg8nKDaA")}

@ -1,29 +1,43 @@
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-unused-vars */
import React, { useContext } from 'react' import React, { useContext } from 'react'
import { ThemeContext } from '../themeContext' import { ThemeContext } from '../themeContext'
import { OverlayTrigger, Tooltip } from 'react-bootstrap' // eslint-disable-line
interface PluginButtonProps { interface PluginButtonProps {
imgPath: string, imgPath: string,
envID: string, envID: string,
envText: string, envText: string,
callback: any, callback: any,
l2?: boolean l2?: boolean,
description: string,
remixMaintained?: boolean
} }
function PluginButton ({ imgPath, envID, envText, callback, l2 }: PluginButtonProps) { function PluginButton ({ imgPath, envID, envText, callback, l2, description, remixMaintained }: PluginButtonProps) {
const themeFilter = useContext(ThemeContext) const themeFilter = useContext(ThemeContext)
return ( return (
<div> <div>
<button <button
className="btn border-secondary d-flex mr-3 text-nowrap justify-content-center flex-column align-items-center remixui_home_envButton" className="btn border-secondary d-flex mr-3 text-nowrap justify-content-center align-items-center remixui_home_envButton"
data-id={'landingPageStart' + envText} data-id={'landingPageStart' + envText}
onClick={() => callback()} onClick={() => callback()}
> >
<img className="m-2 align-self-center remixui_home_envLogo" id={envID} src={imgPath} alt="" style={ { filter: themeFilter.filter } } /> <img className="px-2 m-2 align-self-center remixui_home_envLogo" id={envID} src={imgPath} alt="" style={ { filter: themeFilter.filter } } />
<label className="text-uppercase text-dark remixui_home_cursorStyle">{envText}</label> <div className="h-100 d-flex flex-column">
<label className="text-uppercase text-dark remixui_home_cursorStyle">{envText}</label>
<div className="remixui_home_envLogoDescription">{description}</div>
</div>
</button> </button>
{ l2 && <label className="bg-light mx-1 px-1 mb-0 mx-2 position-relative remixui_home_l2Label">L2</label> } { l2 && <label className="bg-light mx-1 px-1 mb-0 mx-2 position-relative remixui_home_l2Label">L2</label> }
{ remixMaintained &&
<OverlayTrigger placement="bottom" overlay={
<Tooltip id="overlay-tooltip-run-script">
<span>Maintained by Remix</span>
</Tooltip>
}>
<i className="bg-light text-success mx-1 px-1 mb-0 mx-2 position-relative remixui_home_maintainedLabel fas fa-check"></i>
</OverlayTrigger>
}
</div> </div>
) )

@ -63,14 +63,21 @@
opacity: 0.7; opacity: 0.7;
} }
.remixui_home_envLogo { .remixui_home_envLogo {
height: 16px; height: 2.5rem;
}
.remixui_home_envLogoDescription{
white-space: pre-wrap;
font-size: smaller;
line-height: 0.8rem;
text-align: left;
} }
.remixui_home_cursorStyle { .remixui_home_cursorStyle {
cursor: pointer; cursor: pointer;
font-size: 0.7rem;
} }
.remixui_home_envButton { .remixui_home_envButton {
width: 120px; width: 240px;
height: 70px; height: 80px;
} }
.remixui_home_media { .remixui_home_media {
overflow: hidden; overflow: hidden;
@ -84,3 +91,7 @@
.remixui_home_l2Label { .remixui_home_l2Label {
bottom: 10px; bottom: 10px;
} }
.remixui_home_maintainedLabel {
bottom: 10px;
left: 20px;
}

@ -11,6 +11,7 @@ import HomeTabLearn from './components/homeTabLearn'
import HomeTabScamAlert from './components/homeTabScamAlert' import HomeTabScamAlert from './components/homeTabScamAlert'
import HomeTabGetStarted from './components/homeTabGetStarted' import HomeTabGetStarted from './components/homeTabGetStarted'
import HomeTabFeatured from './components/homeTabFeatured' import HomeTabFeatured from './components/homeTabFeatured'
import HomeTabFeaturedPlugins from './components/homeTabFeaturedPlugins'
declare global { declare global {
interface Window { interface Window {
@ -69,51 +70,23 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
} }
}, []) }, [])
const startSolidity = async () => {
await plugin.appManager.activatePlugin(['solidity', 'udapp', 'solidityStaticAnalysis', 'solidityUnitTesting'])
plugin.verticalIcons.select('solidity')
_paq.push(['trackEvent', 'pluginManager', 'userActivate', 'solidity'])
}
const startStarkNet = async () => {
await plugin.appManager.activatePlugin('starkNet_compiler')
plugin.verticalIcons.select('starkNet_compiler')
_paq.push(['trackEvent', 'pluginManager', 'userActivate', 'starkNet_compiler'])
}
const startSolhint = async () => {
await plugin.appManager.activatePlugin(['solidity', 'solhint'])
plugin.verticalIcons.select('solhint')
_paq.push(['trackEvent', 'pluginManager', 'userActivate', 'solhint'])
}
const startLearnEth = async () => {
await plugin.appManager.activatePlugin(['solidity', 'LearnEth', 'solidityUnitTesting'])
plugin.verticalIcons.select('LearnEth')
_paq.push(['trackEvent', 'pluginManager', 'userActivate', 'learnEth'])
}
const startSourceVerify = async () => {
await plugin.appManager.activatePlugin(['solidity', 'sourcify'])
plugin.verticalIcons.select('sourcify')
_paq.push(['trackEvent', 'pluginManager', 'userActivate', 'sourcify'])
}
const startPluginManager = async () => {
plugin.verticalIcons.select('pluginManager')
}
const maxHeight = Math.max(window.innerHeight - 150, 250) + 'px' const maxHeight = Math.max(window.innerHeight - 150, 250) + 'px'
const elHeight = '4000px' const elHeight = '4000px'
return ( return (
<div className="d-flex flex-row w-100" id="remixUIHTAll"> <div className="d-flex flex-row w-100" id="remixUIHTAll">
<div className="px-2 justify-content-between d-flex border-right flex-column" id="remixUIHTLeft" style={{flex: 2}}> <div className="px-2 justify-content-between d-flex border-right flex-column" id="remixUIHTLeft" style={{flex: 2, minWidth: "30%"}}>
<HomeTabTitle /> <HomeTabTitle />
<HomeTabFile plugin={plugin} /> <HomeTabFile plugin={plugin} />
<ThemeContext.Provider value={ state.themeQuality }> <ThemeContext.Provider value={ state.themeQuality }>
<HomeTabLearn plugin={plugin}/> <HomeTabLearn plugin={plugin}/>
</ThemeContext.Provider> </ThemeContext.Provider>
</div> </div>
<div className="px-2 justify-content-between d-flex flex-column" id="remixUIHTRight" style={{flex: 4}}> <div className="pl-2 pr-3 justify-content-between d-flex flex-column" style={{width: "70%"}} id="remixUIHTRight">
<div className="" id="hTFeaturedeSection">
</div>
<HomeTabFeatured></HomeTabFeatured> <HomeTabFeatured></HomeTabFeatured>
<HomeTabFeaturedPlugins plugin={plugin}></HomeTabFeaturedPlugins>
<HomeTabGetStarted></HomeTabGetStarted> <HomeTabGetStarted></HomeTabGetStarted>
<HomeTabScamAlert></HomeTabScamAlert> <HomeTabScamAlert></HomeTabScamAlert>
</div> </div>

@ -4529,6 +4529,11 @@
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw== integrity sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==
"@types/overlayscrollbars@^1.12.1":
version "1.12.1"
resolved "https://registry.yarnpkg.com/@types/overlayscrollbars/-/overlayscrollbars-1.12.1.tgz#fb637071b545834fb12aea94ee309a2ff4cdc0a8"
integrity sha512-V25YHbSoKQN35UasHf0EKD9U2vcmexRSp78qa8UglxFH8H3D+adEa9zGZwrqpH4TdvqeMrgMqVqsLB4woAryrQ==
"@types/parse-json@^4.0.0": "@types/parse-json@^4.0.0":
version "4.0.0" version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
@ -18089,6 +18094,11 @@ outpipe@^1.1.0:
dependencies: dependencies:
shell-quote "^1.4.2" shell-quote "^1.4.2"
overlayscrollbars-react@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/overlayscrollbars-react/-/overlayscrollbars-react-0.3.0.tgz#6d18e741897131643aa8afbc7fed735fbd106c9c"
integrity sha512-dV74p9VL/aImqJpeYz0vmpScZYu6UiNTmRKfyI4CS0OYUpYCUiTd723adY38Grz2W57hoNCECWDzkOJRFDQeZg==
p-cancelable@^0.3.0: p-cancelable@^0.3.0:
version "0.3.0" version "0.3.0"
resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.3.0.tgz#b9e123800bcebb7ac13a479be195b507b98d30fa" resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.3.0.tgz#b9e123800bcebb7ac13a479be195b507b98d30fa"
@ -19712,6 +19722,11 @@ react-lifecycles-compat@^3.0.4:
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA== integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==
react-multi-carousel@^2.8.2:
version "2.8.2"
resolved "https://registry.yarnpkg.com/react-multi-carousel/-/react-multi-carousel-2.8.2.tgz#4bbd7a9656d8e49e081745331593e5500eefdbe4"
integrity sha512-M9Y7DfAp8bA/r6yexttU6RLA7uyppje4c0ELRuCHZWswH+u7nr0uVP6qHNPjc4XGOEY1MYFOb5nBg7JvoKutuQ==
react-overlays@^5.1.1: react-overlays@^5.1.1:
version "5.1.1" version "5.1.1"
resolved "https://registry.yarnpkg.com/react-overlays/-/react-overlays-5.1.1.tgz#2e7cf49744b56537c7828ccb94cfc63dd778ae4f" resolved "https://registry.yarnpkg.com/react-overlays/-/react-overlays-5.1.1.tgz#2e7cf49744b56537c7828ccb94cfc63dd778ae4f"

Loading…
Cancel
Save