Skip to content

Commit a6b06be

Browse files
committed
share icons (always minimal)
1 parent 99016e8 commit a6b06be

File tree

4 files changed

+42
-55
lines changed

4 files changed

+42
-55
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* eslint-disable */
2+
(function(d, s, id) {
3+
var js, fjs = d.getElementsByTagName(s)[0];
4+
if (d.getElementById(id) || !fjs) return;
5+
js = d.createElement(s); js.id = id;
6+
js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8';
7+
fjs.parentNode.insertBefore(js, fjs);
8+
}(document, 'script', 'facebook-jssdk'));
9+
/* eslint-enable */

src/app/components/share/share.scss

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,32 @@ $linkedin-blue: #0077b5;
66

77
.share-buttons {
88
.buttons {
9-
display: flex;
9+
display: grid;
10+
grid-gap: 1rem;
1011
justify-content: center;
11-
margin: 1rem 0;
12-
13-
&:not(.minimal) {
14-
width: 100%;
15-
}
12+
margin: 0;
1613

1714
@include width-up-to($phone-max) {
1815
flex-direction: column;
1916
width: auto;
2017
}
18+
$button-size: 3.2rem;
2119

2220
.btn {
2321
@extend %button;
2422
@extend %secondary;
2523

2624
align-items: center;
2725
background-image: none;
28-
display: flex;
26+
border-radius: 50%;
27+
display: grid;
2928
font-weight: normal;
30-
justify-content: flex-start;
31-
margin: 1rem 0.5rem;
32-
padding-left: 1.5rem;
29+
height: $button-size;
30+
justify-content: center;
31+
margin: 0;
32+
padding: 0;
3333
text-transform: none;
34+
width: $button-size;
3435

3536
&.facebook {
3637
background-color: $facebook-blue;
@@ -46,32 +47,8 @@ $linkedin-blue: #0077b5;
4647

4748
.social-icon {
4849
color: text-color(white);
49-
margin-right: 1rem;
50-
transform: scale(1.5);
51-
}
52-
}
53-
54-
&.minimal {
55-
display: grid;
56-
grid-gap: 1rem;
57-
justify-content: center;
58-
margin: 0;
59-
60-
$button-size: 3.2rem;
61-
.btn {
62-
align-items: center;
63-
border-radius: 50%;
64-
display: grid;
65-
height: $button-size;
66-
justify-content: center;
6750
margin: 0;
68-
padding: 0;
69-
width: $button-size;
70-
71-
.social-icon {
72-
margin: 0;
73-
transform: none;
74-
}
51+
transform: none;
7552
}
7653
}
7754
}

src/app/components/share/share.js renamed to src/app/components/share/share.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
import React from 'react';
22
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
3+
import {IconDefinition} from '@fortawesome/fontawesome-svg-core';
34
import {faFacebookF} from '@fortawesome/free-brands-svg-icons/faFacebookF';
45
import {faXTwitter} from '@fortawesome/free-brands-svg-icons/faXTwitter';
56
import {faLinkedinIn} from '@fortawesome/free-brands-svg-icons/faLinkedinIn';
7+
import './facebook-script';
68
import './share.scss';
79

8-
/* eslint-disable */
9-
(function(d, s, id) {
10-
var js, fjs = d.getElementsByTagName(s)[0];
11-
if (d.getElementById(id) || !fjs) return;
12-
js = d.createElement(s); js.id = id;
13-
js.src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8';
14-
fjs.parentNode.insertBefore(js, fjs);
15-
}(document, 'script', 'facebook-jssdk'));
16-
/* eslint-enable */
10+
type ButtonData = {
11+
aClass: string;
12+
url: string;
13+
icon: IconDefinition;
14+
iconLabel: string;
15+
target?: string;
16+
}
1717

18-
function SocialLink({minimal, aClass, url, icon, iconLabel, target}) {
18+
function SocialLink({aClass, url, icon, iconLabel, target}: ButtonData) {
1919
return (
20-
<a className={aClass} target={target} href={url}>
20+
<a className={aClass} target={target} href={url} aria-label={iconLabel}>
2121
<FontAwesomeIcon className="social-icon" icon={icon} />
22-
{
23-
!minimal && <span>{iconLabel}</span>
24-
}
2522
</a>
2623
);
2724
}
2825

29-
function ShareInterior({pageUrl, message, minimal}) {
26+
type Props = {
27+
pageUrl: string;
28+
message: string;
29+
}
30+
31+
function ShareInterior({pageUrl, message}: Props) {
3032
const buttonData = [
3133
{
3234
aClass: 'fb-xfbml-parse-ignore facebook btn',
@@ -50,25 +52,25 @@ function ShareInterior({pageUrl, message, minimal}) {
5052
];
5153

5254
return (
53-
<div className={`buttons ${minimal ? 'minimal' : ''}`}>
55+
<div className='buttons'>
5456
<div
5557
className="fb-share-button"
5658
data-href="https://developers.facebook.com/docs/plugins/"
5759
data-layout="link"
5860
data-mobile-iframe="true"
5961
>
60-
<SocialLink {...buttonData[0]} minimal={minimal} />
62+
<SocialLink {...buttonData[0]} />
6163
</div>
6264
{
6365
buttonData.slice(1).map((data) =>
64-
<SocialLink {...data} minimal={minimal} key={data} />
66+
<SocialLink {...data} key={data.url} />
6567
)
6668
}
6769
</div>
6870
);
6971
}
7072

71-
export function ShareJsx(props) {
73+
export function ShareJsx(props: Props) {
7274
return (
7375
<div className='share-buttons'>
7476
<ShareInterior {...props} />

src/app/pages/blog/article/article.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ function ShareButtons() {
220220
message={encodeURIComponent(
221221
'Check out this OpenStax blog article!'
222222
)}
223-
minimal={true}
224223
/>
225224
);
226225
}

0 commit comments

Comments
 (0)