HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div id="application" class="application"></div>
$tcolor : #7E9BA0
$dcolor : #f06292 /* #f57c00 */
$ccolor : #f06292
$bcolor: #fff
html,body
height: 100%
font-family: Roboto
font-size: 1em
background: linear-gradient(transparent, #f3f3f3 10%, transparent)
background-size: 4px
*
margin: 0px
padding: 0px
box-sizing: border-box
.application
height: 100%
background-size: cover
display: flex
flex-direction: row
.super-line
color: $bcolor
text-transform: uppercase
font-size: 12px
text-align: center
position: relative
&:before
content: ''
display: inline-block
border-bottom: 1px solid $bcolor
margin-bottom: 3px
margin-right: 20px
width: 80px
&:after
content: ''
display: inline-block
border-bottom: 1px solid $bcolor
margin-bottom: 3px
margin-left: 20px
width: 80px
&.b
background: $bcolor
color: $tcolor
&:before,&:after
border-bottom: 1px solid $tcolor
.wrapper
display: flex
width: 100%
align-items: stretch
.wrapper > .loading
margin: auto
width: 200px
text-align: center
span
display: inline-block
width: 10px
height: 10px
border-radius: 50%
border: 1px solid #880e4f
margin: 0px 10px
opacity: .1
@for $i from 1 through 5
&:nth-child(#{$i})
animation: blink 1.3s infinite
animation-delay: #{'.' +(($i +2) * 100)}s
@keyframes blink
0%
opacity: 1
background: #880e4f
50%
opacity: 1
background: #fff
100%
opacity: .1
background: #fff
.wrapper > .card
margin: auto
width: 360px
border-radius: 5px 5px 0px 0px
background: $ccolor
box-shadow: 6px 6px 8px #999
.header
position: relative
display: flex
align-items: center
flex-direction: column
border-radius: 5px 5px 0px 0px
height: 200px
.avatar, .avatar > img
width: 100px
height: 100px
.avatar
overflow: hidden
border-radius: 100%
border: 3px solid #eee
margin: auto
.wrapper > .card > .header
background: #fff
span.repos-count
position: absolute
left: 130px
top: 90px
background: $dcolor
color: #fff
font-size: 12px
font-weight: bold
display: block
width: 28px
height: 28px
border: 2px solid #fff
line-height: 24px
text-align: center
border-radius: 50%
&:after
content: 'repos'
position: absolute
color: $tcolor
text-transform: uppercase
font-size: 8px
bottom: -20px
left: 0px
a.userlink
background: $tcolor
color: #fff
padding: 4px 10px
position: absolute
right: 0px
top: 0px
text-decoration: none
&:hover
background: $dcolor
i
font-size: 12px
margin: 0px 0px 0px 5px
.userinfo
text-align: center
padding: 0px 0px 20px 0px
h2
color: $tcolor
p
color: $tcolor
.wrapper > .card > .top-repos
display: flex
flex-direction: column
align-items: stretch
padding: 10px 0px 0px 0px
background: $ccolor
text-align: center
.repository
margin: 5px 0px
flex-grow: 1
text-align: center
font-size: 16px
color: #fff
text-decoration: none
i
display: block
margin-bottom: 5px
font-size: 8px
.title
text-transform: uppercase
font-size: 12px
.wrapper > .card > .pie-chart-wrap
position: relative
text-align: center
.pie-chart
margin-top: 40px
.pie-chart-totals
position: absolute
top: 100px
width: 100%
color: #fff
font-weight: bold
font-size: 22px
i
display: block
margin-bottom: 10px
.wrapper > .card > .chart
position: relative
border: none
background: #fff
width: 360px
overflow: hidden
height: 100px
canvas
border: none
position: absolute
left: -5px
bottom: -9px
.wrapper > .card > .activity-line
padding-top: 40px
.wrapper > .card > .totals
display: flex
flex-direction: row
align-items: stretch
padding: 10px 0px 5px 0px
background: $bcolor
& > div
&:nth-child(2)
border-right: 1px solid #ddd
border-left: 1px solid #ddd
flex-grow: 1
text-align: center
font-size: 16px
color: $tcolor
.desc
text-transform: uppercase
font-size: 9px
/*
Home : https://github.com/c0ncept/github-user-card
*/
const GITHUB_USER = 'linuxenko'
const GITHUB_URL = 'https://api.github.com/users/'
Chart.defaults.global = {
animation: true,
animationSteps: 50,
animationEasing: "easeOutBounce",
scaleLabel: "<%=value%>",
bezierCurve: true,
bezierCurveTension: 1,
scaleIntegersOnly: true,
scaleBeginAtZero: false,
maintainAspectRatio: false,
onAnimationProgress: function() {},
onAnimationComplete: function() {}
}
class Repo extends React.Component {
render() {
let {repo} = this.props
return (
<a className="repository" href={repo.html_url}>
<div className="repo-info">
<div><i className="fa fa-star"></i>
<span></span><span className="title">{repo.name}</span>
</div>
</div>
</a>
)
}
}
class DataChart extends React.Component {
eventsRange(event) {
let range = []
for (let i = 11; i > 0; i--) {
range.push(moment().subtract(i, 'days').format('YYYY-MM-DD'))
}
let evtmp = this.props.events
.filter(e => event(e.type))
.map(e => e.created_at.match(/^(\d{4}-\d{2}-\d{2}).*/)[1])
return range.map(r => evtmp.reduce(function(p,c) { return r === c ? p + 1 : p}, 0))
}
componentDidMount() {
let pushEvents = this.eventsRange((e) => e === 'PushEvent')
let miscEvents = this.eventsRange((e) => e !== 'PushEvent')
var lineChartData = {
labels: pushEvents,
datasets: [{
fillColor: "#7E9BA0",
strokeColor: "rgba(0,0,0,0)",
pointColor: "rgba(255, 255, 255, 0)",
pointStrokeColor: "rgba(255, 255, 255, 0)",
data: pushEvents
}, {
fillColor: "#f06292",
strokeColor: "rgba(0,0,0,0)",
pointColor: "rgba(255, 255, 255, 0)",
pointStrokeColor: "rgba(255, 255, 255, 0)",
data: miscEvents
}]
};
var ctx1 = document.getElementById("chart").getContext("2d");
this.chart = new Chart(ctx1).Line(lineChartData);
}
render() {
return (
<div className="chart">
<canvas id="chart" width="370" height="100" />
</div>
)
}
}
class RepoChart extends React.Component {
componentDidMount() {
var htmlData = [
{
value: this.props.repos[0].stargazers_count,
color: "#f8bbd0"
},
{
value : this.props.repos[1].stargazers_count,
color : "#ec407a"
},
{
value : this.props.repos[2].stargazers_count,
color : "#fff"
}
];
var ctx2 = document.getElementById("pie").getContext("2d");
new Chart(ctx2).Doughnut(htmlData, {
segmentShowStroke: false,
percentageInnerCutout : 80
})
}
render() {
let totals = this.props.repos.reduce(function(p,c) {
return p + c.stargazers_count
},0)
return (
<div className="pie-chart-wrap">
<div className="pie-chart-totals">
<i className="fa fa-star"></i>{totals}
</div>
<canvas id="pie" className="pie-chart" width="180" height="180">
</canvas>
</div>
)
}
}
class Card extends React.Component {
render() {
let reposData = this.props.repos
.sort((a,b) => b.stargazers_count - a.stargazers_count)
.slice(0,3)
let repos = reposData
.map((r,i) => <Repo key={i} repo={r} />)
let starred = this.props.repos
.reduce(function(p,c) {return p + Number(c.stargazers_count) }, 0)
let forked = this.props.repos
.reduce(function(p,c) {return p + Number(c.forks_count) }, 0)
return (
<div className="card">
<div className="header">
<a className="userlink" href={this.props.user.html_url}>
{this.props.user.login}
<i className="fa fa-link"></i>
</a>
<div className="avatar">
<img src={this.props.user.avatar_url} />
</div>
<span className="repos-count">
{this.props.user.public_repos}
</span>
<div className="userinfo">
<h2>{this.props.user.name || this.props.user.login}</h2>
<p>{this.props.user.location}</p>
</div>
</div>
<div className="totals">
<div>
{this.props.user.followers}
<div className="desc">Followers</div>
</div>
<div>
{starred}
<div className="desc">Total stars</div>
</div>
<div>
{forked}
<div className="desc">Times Forked</div>
</div>
</div>
<DataChart events={this.props.events} />
<br /><br />
<div className="super-line">TOP Rated</div>
<RepoChart repos={reposData} />
<div className="top-repos">
{repos}
</div>
<br /><br />
</div>
)
}
}
class Application extends React.Component {
constructor() {
super()
this.state = {user : {}, repos : []}
this.loadGitHubUser(GITHUB_USER)
}
loadGitHubUser(user) {
Promise.all([
fetch(GITHUB_URL + user).then(r => r.json()),
fetch(GITHUB_URL + user + '/repos').then(r => r.json()),
fetch(GITHUB_URL + user + '/events?per_page=300').then(r => r.json())
]).then((resp) => {
this.setState({user: resp[0], repos : resp[1], events : resp[2]})
})
}
render() {
let children = this.state.user.hasOwnProperty('login')
? <Card user={this.state.user} repos={this.state.repos} events={this.state.events} />
: <div className="loading"><span></span><span></span><span></span><span></span><span></span></div>
return (
<div className="wrapper">
{children}
</div>
)
}
}
ReactDOM.render(<Application />,
document.getElementById('application'))
Also see: Tab Triggers