Skip to content

Commit

Permalink
restoring social share (#54)
Browse files Browse the repository at this point in the history
* WIP of integrating amd restoring social share

* update version and add stencil/core dep

* remove stencil dep

* got something work for local development

* manual copy of web-social-share dist files

* add support for dynamic import vars

* point back to patched original version of web-social-share

* style and customize web-social-share

* update rollup plugin

* basic styles for event details
  • Loading branch information
thescientist13 authored Dec 31, 2021
1 parent 33ee8fc commit 99ef6ed
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 7 deletions.
9 changes: 9 additions & 0 deletions greenwood.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { greenwoodPluginImportCss } from '@greenwood/plugin-import-css';
import { greenwoodPluginPostCss } from '@greenwood/plugin-postcss';
import analyze from 'rollup-plugin-analyzer';
import { visualizer } from 'rollup-plugin-visualizer';
import dynamicImportVariables from '@rollup/plugin-dynamic-import-vars';

export default {
mode: 'spa',
Expand All @@ -18,6 +19,14 @@ export default {
...greenwoodPluginFontAwesome(),
...greenwoodPluginTypeScript(),
{
type: 'rollup',
name: 'rollup-plugin-import-vars',
provider: () => {
return [
dynamicImportVariables.default()
];
}
}, {
type: 'rollup',
name: 'rollup-plugin-analyzer',
provider: () => {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"lit-redux-router": "~0.19.0",
"pwa-helpers": "^0.9.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
"redux-thunk": "^2.3.0",
"web-social-share": "^8.0.1"
},
"devDependencies": {
"@analogstudiosri/greenwood-plugin-font-awesome": "^0.2.0",
Expand All @@ -49,6 +50,7 @@
"@greenwood/plugin-postcss": "^0.20.0",
"@greenwood/plugin-typescript": "^0.20.0",
"@ls-lint/ls-lint": "^1.10.0",
"@rollup/plugin-dynamic-import-vars": "^1.4.1",
"@storybook/addon-actions": "^6.3.2",
"@storybook/addon-essentials": "^6.3.2",
"@storybook/addon-links": "^6.3.2",
Expand Down
15 changes: 15 additions & 0 deletions src/components/social-share/social-share.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@import '../../theme.css';

button {
background-color: var(--color-tertiary);
border: 2px solid var(--black)!important;
}

svg {
height: 20px;
}

i.fa {
color: #00aced;
width: 1.4rem;
}
70 changes: 70 additions & 0 deletions src/components/social-share/social-share.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { css, html, LitElement, unsafeCSS, TemplateResult } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import socialShareCss from './social-share.css?type=css';
import 'web-social-share';

@customElement('app-social-share')
export class NavigationComponent extends LitElement {
static styles = css`${unsafeCSS(socialShareCss)}`;

@property() show = false;
shareConfig = {};

constructor() {
super();

const socialShareUrl = window.location.href;

this.shareConfig = {
displayNames: true,
config: [{
facebook: {
socialShareUrl
}
}, {
twitter: {
socialShareUrl
}
}, {
pinterest: {
socialShareUrl
}
}]
};
}

connectedCallback() {
super.connectedCallback();

this.shadowRoot.addEventListener('closed', () => {
this.toggleShowSocialShare();
});
}

toggleShowSocialShare() {
this.show = !this.show;
}

protected render(): TemplateResult {
return html`
<div class="container">
<div class="row">
<h2 class="header">Interact + Share</h2>
<button type="button" class="btn" @click=${this.toggleShowSocialShare}>
<svg class="svg-inline--fa fa-share-alt fa-w-14" aria-hidden="true" data-prefix="fas" data-icon="share-alt" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg=""><path fill="currentColor" d="M352 320c-22.608 0-43.387 7.819-59.79 20.895l-102.486-64.054a96.551 96.551 0 0 0 0-41.683l102.486-64.054C308.613 184.181 329.392 192 352 192c53.019 0 96-42.981 96-96S405.019 0 352 0s-96 42.981-96 96c0 7.158.79 14.13 2.276 20.841L155.79 180.895C139.387 167.819 118.608 160 96 160c-53.019 0-96 42.981-96 96s42.981 96 96 96c22.608 0 43.387-7.819 59.79-20.895l102.486 64.054A96.301 96.301 0 0 0 256 416c0 53.019 42.981 96 96 96s96-42.981 96-96-42.981-96-96-96z"></path></svg>
SHARE THIS PAGE
</button>
<web-social-share class="wss" .show=${this.show} .share=${this.shareConfig}>
<i class="fa fa-facebook" slot="facebook"></i>
<i class="fa fa-twitter" slot="twitter"></i>
<i class="fa fa-pinterest" slot="pinterest"></i>
</web-social-share>
</div>
</div>
`;
}
}
3 changes: 2 additions & 1 deletion src/routes/albums/album-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getAlbumById } from '../../services/albums/albums-service.ts';
import { modelAlbum } from '../../components/card/card.model.ts';
import { Album } from '../../services/albums/album.model.ts';
import '../../components/card/card.ts';
import '../../components/social-share/social-share.ts';
import albumsCss from './albums.css?type=css';

@customElement('as-route-album-details')
Expand Down Expand Up @@ -45,7 +46,7 @@ export class AlbumDetailsRouteComponent extends LitElement {
<div class="row">
<div class="col-xs-4 hidden-sm-down">
<as-social-share></as-social-share>
<app-social-share></app-social-share>
</div>
<div class="col-xs-6">
Expand Down
3 changes: 2 additions & 1 deletion src/routes/artists/artist-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { modelArtist, modelAlbum } from '../../components/card/card.model.ts';
import { Artist } from '../../services/artists/artist.model.ts';
import { Album } from '../../services/album/album.model.ts';
import '../../components/card/card.ts';
import '../../components/social-share/social-share.ts';
import artistsCss from './artists.css?type=css';

@customElement('as-route-artist-details')
Expand Down Expand Up @@ -56,7 +57,7 @@ export class ArtistDetailsRouteComponent extends LitElement {
<div class="row">
<div class="col-xs-4 hidden-sm-down">
<as-social-share></as-social-share>
<app-social-share></app-social-share>
</div>
<div class="col-xs-6">
Expand Down
6 changes: 3 additions & 3 deletions src/routes/events/event-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
import { customElement, property } from 'lit/decorators.js';
import { getEventById } from '../../services/events/events-service.ts';
import { Event } from '../../services/events/event.model.ts';
import '../../components/social-share/social-share.ts';
import eventsCss from './events.css?type=css';

@customElement('as-route-event-details')
Expand Down Expand Up @@ -50,17 +51,16 @@ export class EventDetailsRouteComponent extends LitElement {
</style>
<div class="as-events-container">
<div id="as-event-detail-container">
<i class="cal-icon fa fa-calendar-o" style="font-size: 5rem;width:20%"></i>
<app-social-share></app-social-share>
<i class="cal-icon fa fa-calendar-o" style="font-size: 5rem;width:10%"></i>
<div id="as-event-info">
<p>Event Title: ${event.title}</p>
<p>Event Date: ${this.formatEventTime(event.startTime)}</p>
<p>Event Info:</p>
<p style="color: var(--color-primary)">${unsafeHTML(event.description)}</p>
</div>
</div>
<as-social-share></as-social-share>
</div>
`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/events/events.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#as-event-detail-container {
display: flex;
font-size: 1.2rem;
padding: 3rem;
padding: 2rem;

@media(max-width: 768px) {
flex-direction: column;
Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,16 @@
prop-types "^15.6.1"
react-lifecycles-compat "^3.0.4"

"@rollup/plugin-dynamic-import-vars@^1.4.1":
version "1.4.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-dynamic-import-vars/-/plugin-dynamic-import-vars-1.4.1.tgz#ef6d042cd826ba05df6975c8a2612700cf0820ce"
integrity sha512-izHpMs9w8U8CLwyHTXE55H4ytGVaf2ZtlKIWxKigghw6ZC6Mx6AXCsixSY6JOchuX9BN4ZkeN8egLRTS+BxO+w==
dependencies:
"@rollup/pluginutils" "^3.1.0"
estree-walker "^2.0.1"
globby "^11.0.1"
magic-string "^0.25.7"

"@rollup/plugin-node-resolve@^11.0.1":
version "11.2.1"
resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz#82aa59397a29cd4e13248b106e6a4a1880362a60"
Expand Down Expand Up @@ -5722,6 +5732,11 @@ estree-walker@^1.0.1:
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700"
integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==

estree-walker@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==

esutils@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
Expand Down Expand Up @@ -12672,6 +12687,11 @@ web-namespaces@^1.0.0:
resolved "https://registry.yarnpkg.com/web-namespaces/-/web-namespaces-1.1.4.tgz#bc98a3de60dadd7faefc403d1076d529f5e030ec"
integrity sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw==

web-social-share@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/web-social-share/-/web-social-share-8.0.1.tgz#460fc6120f97371a840bec2b87e2a7a5bed26360"
integrity sha512-SdYm76yaFDRbAm+2n+mVi7q/tgg+UqX8BDKwvIWTymssfB9CfyH9uyXPzh2o3Kfa1SIeIGY0lmExxVLdYdGueA==

webidl-conversions@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-6.1.0.tgz#9111b4d7ea80acd40f5270d666621afa78b69514"
Expand Down

0 comments on commit 99ef6ed

Please sign in to comment.