Skip to content

Commit

Permalink
Merge pull request #89 from salesforce-ux/github-button
Browse files Browse the repository at this point in the history
GitHub button
  • Loading branch information
Dottenpixel committed Nov 6, 2015
2 parents 300c066 + 319b36e commit e1e907d
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 25 deletions.
84 changes: 84 additions & 0 deletions app_modules/site/components/github-button/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
Copyright (c) 2015, salesforce.com, inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import React from 'react';
import classNames from 'classnames';
import { createChainedFunction } from 'app_modules/ui/util/component';
import { logCTAEvent } from 'app_modules/site/util/analytics';
import { Link } from 'react-router';
import { find } from 'lodash';
import sitemap from 'app_modules/site/navigation/sitemap';
import CTALink from 'app_modules/site/components/cta-link';

const componentUtil = require('app_modules/ui/util/component');
const pf = componentUtil.prefix;

class GithubButton extends React.Component {
constructor(props) {
super(props);

this.state = {
stargazersCount: 0,
repoData: {}
};
}

getStars(cb) {
const req = new XMLHttpRequest()
req.onreadystatechange = () => {
if (req.readyState == 4) {
const json = JSON.parse(req.responseText);
cb(json);
}
}
req.open('GET', 'https://api.github.com/repos/salesforce-ux/design-system', true);
req.send();
}

componentDidMount() {
this.getStars((data) => {
this.setState({
stargazersCount: data.stargazers_count,
repoData: data
});
}.bind(this))
}

render() {
const linkUrlRepo = this.state.repoData.html_url;
const linkUrlGazer = linkUrlRepo + '/stargazers';
const countStr = String(this.state.stargazersCount).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
const classesButtonGroup = classNames('site-button-group--social-counter', pf('button'));
const classesBubbleButton = classNames('site-button--social-counter',
pf('button button--neutral nubbin--left')
);
const classesBubble = classNames('site-button--social-counter-bubble',
(this.state.stargazersCount > 0 ? 'is-loaded' : '')
);
return (
<span className={classesButtonGroup}>
<CTALink href={linkUrlRepo} className={pf('button button--neutral')}>
<img src='/assets/images/social-github-icon-only.svg' className={pf('button__icon--large button__icon--left')}/>
Star
</CTALink>
<a href={linkUrlGazer} className={classesBubbleButton}>
<span className={classesBubble}>{countStr}</span>
</a>
</span>
)
}

}

GithubButton.displayName = 'GithubButton';
GithubButton.propTypes = {};

module.exports = GithubButton;
17 changes: 17 additions & 0 deletions site/assets/images/social-github-icon-only.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions site/assets/styles/_site/page-types/landing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,25 @@

}

// Social Counter Button Pair
.site-button-group--social-counter {
.slds-button + .slds-button {
margin: {
left: $spacing-small;
}
}
}
.site-button--social-counter {
&-bubble {
opacity: 0;
transition: opacity $duration-immediately ease;

&.is-loaded {
opacity: 1;
}
}
}




Expand Down
6 changes: 3 additions & 3 deletions site/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND

import React from 'react';
import CTALink from 'app_modules/site/components/cta-link';
import GithubButton from 'app_modules/site/components/github-button';
import SvgIcon from 'app_modules/ui/svg-icon';
import PageBody from 'app_modules/site/components/page/body';
import version from '.generated/site.version';
Expand Down Expand Up @@ -53,9 +54,8 @@ class Overview extends React.Component {
</h2>
<IfPrefs userType="external">
<p className={pf('site-cta-buttons m-bottom--medium')}>
<CTALink href="/getting-started" className={pf('button button--neutral site-cta-tutorial')}
ctaEventName='tutorials-top'>Read Tutorials</CTALink> <CTALink href="/resources/downloads"
className={pf('button button--neutral button-space-left site-cta-download')} ctaEventName='downloads-top'>Get the Design System</CTALink>
<CTALink href="/resources/downloads" className={pf('button button--neutral site-cta-download')} ctaEventName='downloads-top'>Get the Design System</CTALink>
<GithubButton></GithubButton>
</p>
</IfPrefs>
<p className={pf('m-bottom--medium')}>Current release: <CTALink href="/release-notes" ctaEventName='release-notes-top'>{version.sldsVersion}</CTALink></p>
Expand Down
53 changes: 31 additions & 22 deletions site/resources/downloads/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,14 @@ export default (
We provide multiple options for downloading the Design System, as well as specific downloads for icons, design tokens and swatches.
</p>

<h2 className="site-text-heading--large" id="framework">Design System Zip</h2>
<p>
Download the pre-built <abbr title="Cascading Style Sheets">CSS</abbr> framework, font
and icons to include in your project. See
the <CTALink href="/release-notes" ctaEventName='release-notes-top'>release notes</CTALink> for
details on the latest updates.
</p>
<p>
All source code is licensed under <a href="http://opensource.org/licenses/BSD-2-Clause">BSD License Clause 2</a>. All icons and images are licensed under <a href="http://creativecommons.org/licenses/by-nd/4.0/">Creative Commons Attribution-NoDerivatives 4.0</a>. The font is licensed under our <a href="/assets/licenses/License-for-font.txt">font license</a>.
</p>
<form action={links.zip.framework}>
<button className={pf('button button--neutral')} onClick={()=>{logDownloadEvent('css'); }}>
Download Design System ({version.sldsVersion})
</button>
</form>

<h2 className="site-text-heading--large" id="unmanaged">Design System Unmanaged Package</h2>

<h2 className="site-text-heading--large" id="framework">Find us on GitHub</h2>
<p>
If you are working within a Salesforce org, the Design System can be installed directly as an unmanaged package:
Instead of downloading the Design System you can also <a href='https://github.com/salesforce-ux/design-system'>fork or clone on Github</a>.
</p>
<ul className={pf('list--dotted')}>
{unmanagedPackageUrls()}
</ul>
<CTALink href='https://github.com/salesforce-ux/design-system' className={pf('button button--neutral')}>
<img src='/assets/images/social-github-icon-only.svg' className={pf('button__icon--large button__icon--left')}/>
Design System on GitHub
</CTALink>

<h2 className="site-text-heading--large" id="unmanaged">Design System Npm Module</h2>

Expand All @@ -89,6 +73,31 @@ bower install salesforce-lightning-design-system
`}</CodeBlock>
</div>

<h2 className="site-text-heading--large" id="framework">Design System Zip</h2>
<p>
Download the pre-built <abbr title="Cascading Style Sheets">CSS</abbr> framework, font
and icons to include in your project. See
the <CTALink href="/release-notes" ctaEventName='release-notes-top'>release notes</CTALink> for
details on the latest updates.
</p>
<p>
All source code is licensed under <a href="http://opensource.org/licenses/BSD-2-Clause">BSD License Clause 2</a>. All icons and images are licensed under <a href="http://creativecommons.org/licenses/by-nd/4.0/">Creative Commons Attribution-NoDerivatives 4.0</a>. The font is licensed under our <a href="/assets/licenses/License-for-font.txt">font license</a>.
</p>
<form action={links.zip.framework}>
<button className={pf('button button--neutral')} onClick={()=>{logDownloadEvent('css'); }}>
Download Design System ({version.sldsVersion})
</button>
</form>

<h2 className="site-text-heading--large" id="unmanaged">Design System Unmanaged Package</h2>

<p>
If you are working within a Salesforce org, the Design System can be installed directly as an unmanaged package:
</p>
<ul className={pf('list--dotted')}>
{unmanagedPackageUrls()}
</ul>

<h2 className="site-text-heading--large" id="icons">Icons</h2>
<p>
Download all <CTALink href="/resources/icons" ctaEventName='icons-link-click'>icon sets</CTALink>. Each icon is
Expand Down

0 comments on commit e1e907d

Please sign in to comment.