diff --git a/src/assets/chesscom-embed/default.svg b/src/assets/chesscom-embed/default.svg new file mode 100644 index 0000000..926b604 --- /dev/null +++ b/src/assets/chesscom-embed/default.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/chesscom-embed/diamonds.png b/src/assets/chesscom-embed/diamonds.png new file mode 100644 index 0000000..95ebe03 Binary files /dev/null and b/src/assets/chesscom-embed/diamonds.png differ diff --git a/src/assets/css/App.css b/src/assets/css/App.css index 9ab2d9a..16446dd 100644 --- a/src/assets/css/App.css +++ b/src/assets/css/App.css @@ -527,6 +527,105 @@ a { justify-content: center; } +.chess{ + width: 300px; + height: calc(125px + 2em); + border: none; +} + +#chessProfile { + border-radius: 5px; + width: 300px; + height: calc(125px + 2em); + color: #AAAAAA; + display: grid; + grid-template-columns: 1fr 1fr; + cursor: pointer; +} + +.chessInfo { + background-color: rgba(0,0,0,.3);; + margin: 1em; +} + +.identity { + margin-right: 0px; +} + +.identity h5 { + margin: 0px; + margin-top: -25px; + background: black; + z-index: 50; + position: relative; + width: 90%; + margin-left: 10px; + +} + +.pfpContainer { + display: flex; + justify-content: center; + height: 100%; +} + +.pfpContainer > div { + display: flex; + flex-direction: column; + justify-content: center; +} + +.pfp { + border-radius: 50%; + width: 100px; + text-align: center; +} + +.vContainer { + display: flex; + flex-direction: column; + max-height: 100%; + max-width: 100%; +} + +.vItem { + display: inline-block; +} + +.vItem p { + margin: 0px; + display: inline; +} + +.chessIcon { + display: inline-block; + font-family: Chess New; + font-size: x-large; + width: 25px; + text-align: center; +} + +.rapid { + color: #6c9d41; +} + +.blitz { + color: #f7c045; +} + +.bullet { + color: #a58a45; +} + +.puzzles { + color: #db7e3b; +} + +@font-face { + font-family: Chess New; + src: url('https://www.chess.com/bundles/web/fonts/chessglyph-new.0cc8115c.woff2'); +} + @media screen and (max-width: 1200px) { #menu { diff --git a/src/componets/ChessBed.js b/src/componets/ChessBed.js new file mode 100644 index 0000000..2bb1d98 --- /dev/null +++ b/src/componets/ChessBed.js @@ -0,0 +1,92 @@ +import React from "react"; +import bg from "../assets/chesscom-embed/diamonds.png"; +import def from '../assets/chesscom-embed/default.svg' + +export default class ChessBed extends React.Component { + constructor(props) { + super(props); + this.seeAccount = this.seeAccount.bind(this, props.username); + this.addChessEmbed = this.addChessEmbed.bind(this, props.username); + this.state = { + name: 'Loading..', + pic: def, + ratings: { + rapid: 'Loading', + blitz: 'Loading', + bullet: 'Loading', + tactics: 'Loading' + } + } + this.diamonds = { + background: "black", + backgroundImage: `linear-gradient(rgba(0, 0, 0, .5), rgba(0, 0, 0, .75)), url(${bg})`, + }; + } + + seeAccount(username) { + window.top.location.href = "https://chess.com/member/" + username; + } + + async addChessEmbed(username){ + let user = await fetch(`https://api.chess.com/pub/player/${username}`); + let stats = await fetch(`https://api.chess.com/pub/player/${username}/stats`); + if(user.status === 200){ + user = await user.json(); + stats = await stats.json(); + this.setState({ + name: user['username'], + pic: user.avatar, + ratings: { + rapid: stats.chess_rapid.last.rating, + blitz: stats.chess_blitz.last.rating, + bullet: stats.chess_bullet.last.rating, + tactics: stats.tactics.highest.rating + } + }); + } + else { + this.setState({ + name: "User Not Found" + }); + } + } + + componentDidMount(){ + this.addChessEmbed(); + } + + render() { + return ( + <> +
{this.state.ratings.rapid}
+{this.state.ratings.blitz}
+{this.state.ratings.bullet}
+{this.state.ratings.tactics}
+