-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update home friend links * upgrade docusaurus version * home docusaurus upgrade * home docusaurus upgrade
- Loading branch information
Showing
23 changed files
with
4,958 additions
and
6,202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,56 @@ | ||
import React from 'react' | ||
import clsx from 'clsx' | ||
import styles from './LogoCarousel.module.css' | ||
|
||
const INTERVAL_LENGTH = 5000 | ||
const LOGO_WIDTH = 150 | ||
const cdnUrl = 'https://cdn.jsdelivr.net/gh/usthe/sureness@gh-pages/img/icons/' | ||
|
||
let ticks = 0 | ||
import "slick-carousel/slick/slick.css"; | ||
import "slick-carousel/slick/slick-theme.css"; | ||
import Slider from "react-slick"; | ||
|
||
const cdnUrl = 'https://cdn.jsdelivr.net/gh/dromara/hertzbeat@gh-pages/img/icons/' | ||
|
||
// const cdnUrl = '/img/icons/' | ||
|
||
var settings = { | ||
dots: false, | ||
infinite: true, | ||
speed: 800, | ||
slidesToShow: 6, | ||
slidesToScroll: 1, | ||
autoplay: true, | ||
autoplaySpeed: 800, | ||
rows: 1, | ||
vertical: false | ||
}; | ||
|
||
export default class LogoCarousel extends React.Component { | ||
constructor (props) { | ||
super(props) | ||
this.state = { | ||
position: -0, | ||
activePage: 0, | ||
swapInterval: 0, | ||
pages: Math.ceil(props.logos ? props.logos.length / 6 : 1), | ||
margin: 70 | ||
} | ||
|
||
this.imgUrl = | ||
|
||
this.containerRef = React.createRef() | ||
} | ||
|
||
componentDidMount() { | ||
const rect = this.containerRef.current.getBoundingClientRect() | ||
const logosPerPage = Math.floor(rect.width / LOGO_WIDTH) | ||
this.setState({ | ||
swapInterval: setInterval(this.nextPage.bind(this), INTERVAL_LENGTH), | ||
pages: Math.ceil(this.props.logos ? this.props.logos.length / logosPerPage : 1), | ||
margin: rect.width < 700 ? 0 : 70 | ||
}) | ||
} | ||
|
||
componentWillUnmount () { | ||
clearInterval(this.state.swapInterval) | ||
} | ||
|
||
animateTo (i) { | ||
const width = this.containerRef.current.getBoundingClientRect().width - this.state.margin | ||
const x = i * -width | ||
this.setState({ position: x, activePage: i }) | ||
} | ||
|
||
handleClick (i) { | ||
this.animateTo(i) | ||
clearInterval(this.state.swapInterval) | ||
this.setState({ | ||
swapInterval: setInterval(this.nextPage.bind(this), INTERVAL_LENGTH) | ||
}) | ||
} | ||
|
||
nextPage () { | ||
const pages = this.state.pages - 1 | ||
const direction = Math.floor(ticks / pages) % 2 | ||
this.animateTo(direction | ||
? pages - (ticks % pages) | ||
: ticks % pages | ||
) | ||
++ticks | ||
} | ||
|
||
render () { | ||
if (!this.props || !this.props.logos) { | ||
return ( | ||
<div></div> | ||
<div/> | ||
) | ||
} | ||
|
||
this.buttons = () => [...Array(this.state.pages)].map((_, index) => ( | ||
<button onClick={() => this.handleClick(index)} key={index} className={clsx(styles.button, index === this.state.activePage ? styles.buttonActive : '')}>{index + 1}</button> | ||
)) | ||
|
||
this.list = () => ( | ||
<ul style={{ transform: `translate(${this.state.position}px, 0px)` }}> | ||
<Slider {...settings}> | ||
{this.props.logos.map((value, index) => ( | ||
<li key={index}><a href={value.url} target="_blank" rel="noopener noreferrer"><img src={cdnUrl + value.img} alt={value.alt} /></a></li> | ||
<a key={index} href={value.url} target="_blank" rel="noopener noreferrer"> | ||
<img style={{ maxHeight: '80px', maxWidth: '100px' }} src={cdnUrl + value.img} alt={value.alt} /> | ||
</a> | ||
))} | ||
</ul> | ||
</Slider> | ||
) | ||
|
||
return ( | ||
<div className={styles.companyUsage} ref={this.containerRef}> | ||
<h3>{this.props.headerTitle}</h3> | ||
<div className={clsx(styles.logos)}> | ||
{this.list()} | ||
<div className={styles.logoNavigation}> | ||
{this.buttons()} | ||
<> | ||
<div className={styles.companyUsage} ref={this.containerRef}> | ||
<h3>{this.props.headerTitle}</h3> | ||
<div className={clsx(styles.logos)}> | ||
{this.list()} | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.