Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KBHBIB-24 Added new share buttons #796

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@import "./src/stories/Library/link-filters/link-filters";
@import "./src/stories/Library/Arrows/arrows";
@import "./src/stories/Library/Buttons/button/buttons";
@import "./src/stories/Library/Buttons/button-share/button-share";
@import "./src/stories/Library/Buttons/button-ui/buttons-ui";
@import "./src/stories/Library/tag/tag";
@import "./src/stories/Library/logo/logo";
Expand Down
3 changes: 3 additions & 0 deletions public/icons/collection/Link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/social/icon-social-facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions src/stories/Library/Buttons/button-share/ButtonShare.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { StoryFn, Meta } from "@storybook/react";

import { ButtonShare } from "./button-share";

export default {
title: "Library / Buttons / Button Share",
component: ButtonShare,
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/design/ewyxJIi7OGXT5ekgDgPK46/KK-bib-deling?node-id=2-2&node-type=frame&t=08x3dd2K8R0fQTaP-0",
},
layout: "centered",
},
argTypes: {
href: {
control: "text",
},
textFacebook: {
control: "text",
},
textCopy: {
control: "text",
},
},
args: {
href: "https://www.facebook.com",
textFacebook: "Del på Facebook",
textCopy: "Kopier link",
},
} as Meta<typeof ButtonShare>;

const Template: StoryFn<typeof ButtonShare> = (args) => (
<ButtonShare {...args} />
);

export const share = Template.bind({});
41 changes: 41 additions & 0 deletions src/stories/Library/Buttons/button-share/button-share.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.button-share {
display: flex;

&:not(&--fixed) {
gap: $s-md;
flex-wrap: wrap;
}

&--fixed {
display: none;
position: fixed;
left: 0;
top: 50%;
z-index: $z-10;
flex-direction: column;
transform: translateY(-50%);

@include media-query__medium {
display: flex;
}
}

&__button {
/* stylelint-disable scss/at-extend-no-missing-placeholder*/
@extend .btn-primary;
@extend .btn-outline;
@extend .btn-medium;

gap: $s-sm;
background-color: $color__global-primary;

&--fixed {
padding: 0;
aspect-ratio: 1;

&:first-child {
border-bottom: unset;
}
}
}
}
53 changes: 53 additions & 0 deletions src/stories/Library/Buttons/button-share/button-share.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { ReactComponent as LinkSvg } from "../../../../public/icons/collection/Link.svg";
import { ReactComponent as FacebookSvg } from "../../../../public/icons/social/icon-social-facebook.svg";

export type ButtonShareProps = {
href: string;
textFacebook: string;
textCopy: string;
};

export const ButtonShare = ({
href,
textFacebook,
textCopy,
}: ButtonShareProps) => {
return (
<div className="button-share">
<div className="button-share button-share--fixed">
<a
JacobArrow marked this conversation as resolved.
Show resolved Hide resolved
href={href}
aria-label="Del denne side på Facebook"
className="button-share__button button-share__button--fixed"
>
<FacebookSvg role="img" aria-hidden="true" />
</a>
<button
type="button"
onClick={() => navigator.clipboard.writeText(href)}
aria-label="Kopier denne side til udklipsholderen"
className="button-share__button button-share__button--fixed"
>
<LinkSvg role="img" aria-hidden="true" />
</button>
</div>
<a
JacobArrow marked this conversation as resolved.
Show resolved Hide resolved
href={href}
aria-label="Del denne side på Facebook"
className="button-share__button"
>
<FacebookSvg role="img" aria-hidden="true" />
{textFacebook}
</a>
<button
type="button"
onClick={() => navigator.clipboard.writeText(href)}
aria-label="Kopier denne side til udklipsholderen"
className="button-share__button"
>
<LinkSvg role="img" aria-hidden="true" />
{textCopy}
</button>
</div>
);
};
Loading