Skip to content

Commit

Permalink
feat: o-share Bluesky buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
aendra-rininsland committed Dec 23, 2024
1 parent 4022d60 commit b409093
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 20 deletions.
6 changes: 6 additions & 0 deletions components/o-share/demos/src/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"link": "https://x.com/intent/tweet?url=http%3A%2F%2Fon.ft.com%2F1mUdgA2&text=US%20drugs&related=ftcompanies&via=FT",
"svg": "<svg viewBox='0 0 1024 1024' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M554.158 472.797L740.663 256H696.467L534.525 444.242L405.182 256H256L451.592 540.655L256 768H300.198L471.213 569.21L607.809 768H756.991L554.158 472.797ZM316.123 289.272H384.009L696.488 736.241H628.602L316.123 289.272Z' /></svg>"
},
{
"name": "Bluesky",
"className": "bluesky",
"link": "https://bsky.app/intent/compose?text=US%20drugs%20via%20%40financialtimes.com%0Ahttp%3A%2F%2Fon.ft.com%2F1mUdgA2",
"svg": "<svg viewBox=\"-256 -256 1024 1024\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M123.121 33.6637C188.241 82.5526 258.281 181.681 284 234.873C309.719 181.681 379.759 82.5526 444.879 33.6637C491.866 -1.61183 568 -28.9064 568 57.9464C568 75.2916 558.055 203.659 552.222 224.501C531.947 296.954 458.067 315.434 392.347 304.249C507.222 323.8 536.444 388.56 473.333 453.32C353.473 576.312 301.061 422.461 287.631 383.039C285.169 375.812 284.017 372.431 284 375.306C283.983 372.431 282.831 375.812 280.369 383.039C266.939 422.461 214.527 576.312 94.6667 453.32C31.5556 388.56 60.7778 323.8 175.653 304.249C109.933 315.434 36.0535 296.954 15.7778 224.501C9.94525 203.659 0 75.2916 0 57.9464C0 -28.9064 76.1345 -1.61183 123.121 33.6637Z\" /></svg>"
},
{
"name": "Facebook",
"className": "facebook",
Expand Down
5 changes: 3 additions & 2 deletions components/o-share/src/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $o-share-ft-icons-names: (corporate, mail, link, share, 'bookmark-outline');

/// List of accepted social network icons, and the version
/// @type Map
$_o-share-icons: (x, facebook, linkedin, link, share, mail, pinterest, whatsapp, corporate, 'bookmark-outline');
$_o-share-icons: (x, facebook, linkedin, link, share, mail, pinterest, whatsapp, corporate, 'bookmark-outline', bluesky);

/// A map of icons to their colour.
/// @type Map
Expand All @@ -47,5 +47,6 @@ $_o-share-colors: (
facebook: #3b579d,
linkedin: #0077b5,
pinterest: #bd081c,
whatsapp: #25d366
whatsapp: #25d366,
bluesky: #0385ff
);
4 changes: 4 additions & 0 deletions components/o-share/src/tsx/shareIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type IconType =
| "facebook"
| "linkedin"
| "whatsapp"
| "bluesky"

export type UrlProps = {
url: string;
Expand Down Expand Up @@ -86,8 +87,10 @@ function generateDescriptiveLinkText(title: string, socialNetwork: IconType) {
linkedin: `Share ${title} on LinkedIn (opens a new window)`,
pinterest: `Share ${title} on Pinterest (opens a new window)`,
whatsapp: `Share ${title} on Whatsapp (opens a new window)`,
bluesky: `Share ${title} on Bluesky (opens a new window)`,
link: `Open link in new window`,
enterpriseSharing: `Share ${title} with your Enterprise Sharing tools (opens a new window)`,

};
return descriptiveLinkText[socialNetwork];
}
Expand Down Expand Up @@ -120,6 +123,7 @@ function generateSocialUrl(
linkedin: `http://www.linkedin.com/shareArticle?mini=true&url=${url}&title=${title}+%7C+${titleExtra}&summary=${summary}&source=Financial+Times`,
pinterest: `http://www.pinterest.com/pin/create/button/?url=${url}&description=${title}`,
whatsapp: `whatsapp://send?text=${title}%20(${titleExtra})%20-%20${url}`,
bluesky: `https://bsky.app/intent/compose?text=${title}%20via%20%40financialtimes.com%0A${url}`,
link: url,
enterpriseSharing: url,
};
Expand Down
12 changes: 12 additions & 0 deletions components/o-share/src/tsx/svgComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const iconMap = {
facebook: <FacebookSVG />,
linkedin: <LinkedInSVG />,
whatsapp: <WhatsappSVG />,
bluesky: <BlueskySVG />,
};

function XSVG() {
Expand Down Expand Up @@ -38,3 +39,14 @@ function WhatsappSVG() {
</svg>
);
}

function BlueskySVG() {
return (
<svg
viewBox="-256 -256 1024 1024"
fill="none"
xmlns="http://www.w3.org/2000/svg">
<path d="M123.121 33.6637C188.241 82.5526 258.281 181.681 284 234.873C309.719 181.681 379.759 82.5526 444.879 33.6637C491.866 -1.61183 568 -28.9064 568 57.9464C568 75.2916 558.055 203.659 552.222 224.501C531.947 296.954 458.067 315.434 392.347 304.249C507.222 323.8 536.444 388.56 473.333 453.32C353.473 576.312 301.061 422.461 287.631 383.039C285.169 375.812 284.017 372.431 284 375.306C283.983 372.431 282.831 375.812 280.369 383.039C266.939 422.461 214.527 576.312 94.6667 453.32C31.5556 388.56 60.7778 323.8 175.653 304.249C109.933 315.434 36.0535 296.954 15.7778 224.501C9.94525 203.659 0 75.2916 0 57.9464C0 -28.9064 76.1345 -1.61183 123.121 33.6637Z" />
</svg>
);
}
4 changes: 2 additions & 2 deletions components/o-share/stories/docs/sassdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Output all o-share styles.

| Parameter | Type | Default | Description |
| --------- | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| opts | Map | ('icons': ('x', 'facebook', 'linkedin', 'link', 'share', 'mail', 'pinterest', 'whatsapp', 'corporate'), 'sizes': ('small'), 'vertical': true, 'inverse': true) | The o-share variants to include styles for (see the README for more details). |
| opts | Map | ('icons': ('x', 'facebook', 'linkedin', 'link', 'share', 'mail', 'pinterest', 'whatsapp', 'corporate', 'bluesky'), 'sizes': ('small'), 'vertical': true, 'inverse': true) | The o-share variants to include styles for (see the README for more details). |

#### Examples

Expand All @@ -39,7 +39,7 @@ styles for select variants.

```Output
@include oShare($opts: (
'icons': ('x', 'facebook', 'linkedin', 'link', 'share', 'mail', 'pinterest', 'whatsapp', 'corporate'),
'icons': ('x', 'facebook', 'linkedin', 'bluesky', 'link', 'share', 'mail', 'pinterest', 'whatsapp', 'corporate'),
'sizes': ('small'),
'vertical': true,
'inverse': true
Expand Down
27 changes: 14 additions & 13 deletions components/o-share/stories/share.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Story, ComponentMeta } from "@storybook/react";
import {Story, ComponentMeta} from '@storybook/react';

import { Share } from "../src/tsx/share";
import { ShareIcon, UrlProps } from "../src/tsx/shareIcon";
import { useEffect, ComponentProps } from "react";
import javascript from "../main";
import "./share.scss";
import {Share} from '../src/tsx/share';
import {ShareIcon, UrlProps} from '../src/tsx/shareIcon';
import {useEffect, ComponentProps} from 'react';
import javascript from '../main';
import './share.scss';

export default {
title: "Components/o-share",
title: 'Components/o-share',
component: Share,
args: {
title: "US drugs",
url: "http://on.ft.com/1mUdgA2",
titleExtra: "FT.com | Pharmaceuticals",
summary: "US drugs group vows to maintain big British presence",
relatedXAccounts: "ftcompanies",
title: 'US drugs',
url: 'http://on.ft.com/1mUdgA2',
titleExtra: 'FT.com | Pharmaceuticals',
summary: 'US drugs group vows to maintain big British presence',
relatedXAccounts: 'ftcompanies',
small: false,
inverse: false,
vertical: false,
Expand All @@ -40,6 +40,7 @@ const StoryTemplate: Story<ShareProps> = args => {
return (
<Share {...shareProps}>
<ShareIcon icon="x" urlProps={shareIconProps} />
<ShareIcon icon="bluesky" urlProps={shareIconProps} />
<ShareIcon icon="facebook" urlProps={shareIconProps} />
<ShareIcon icon="linkedin" urlProps={shareIconProps} />
<ShareIcon icon="whatsapp" urlProps={shareIconProps} />
Expand All @@ -58,7 +59,7 @@ Inverse.args = {
inverse: true,
};
Inverse.parameters = {
origamiBackground: "slate",
origamiBackground: 'slate',
};
export const Vertical: Story<ShareProps> = StoryTemplate.bind({});
Vertical.args = {
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b409093

Please sign in to comment.