Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
chore: update versions, better build phase
Browse files Browse the repository at this point in the history
  • Loading branch information
jukben committed Aug 17, 2018
1 parent c5af6ae commit 5b17e11
Show file tree
Hide file tree
Showing 31 changed files with 1,836 additions and 18,090 deletions.
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

27 changes: 7 additions & 20 deletions app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@
"name": "__MSG_appName__",
"short_name": "__MSG_appShortName__",
"description": "__MSG_appDescription__",
"version": "1.0.3",
"version": "1.1.0",
"manifest_version": 2,
"default_locale": "en",
"web_accessible_resources": [
"sounds/*"
],
"web_accessible_resources": ["sounds/*"],
"icons": {
"16": "images/icon-16.png",
"128": "images/icon-128.png"
},
"background": {
"scripts": [
"scripts/background.js"
]
"scripts": ["scripts/background.js"]
},
"permissions": [
"storage"
],
"permissions": ["storage"],
"page_action": {
"default_title": "__MSG_browserActionTitle__"
},
Expand All @@ -30,16 +24,9 @@
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"css": [
"styles/contentscript.css"
],
"js": [
"scripts/contentscript.js"
],
"matches": ["http://*/*", "https://*/*"],
"css": ["styles/contentscript.css"],
"js": ["scripts/contentscript.js"],
"run_at": "document_end",
"all_frames": false
}
Expand Down
20 changes: 10 additions & 10 deletions app/scripts/Clappe/Clappe.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { observer } from 'mobx-react';
import classNames from 'classnames';
import { store } from './index';
import { CLAP_LIMIT, CLAP_TYPE } from '../constants';
import React from "react";
import { observer } from "mobx-react";
import classNames from "classnames";
import { store } from "./index";
import { CLAP_LIMIT, CLAP_TYPE } from "../constants";

class ClappeContainer extends React.Component {
isDisabled() {
Expand All @@ -22,11 +22,11 @@ class ClappeContainer extends React.Component {
<div
tabIndex={-1}
role="button"
className={classNames('clappe__superClap', {
'clappe__superClap--disabled': this.isDisabled(),
'clappe__superClap--left': type === CLAP_TYPE.LEFT,
'clappe__superClap--footer': type === CLAP_TYPE.FOOTER,
'clappe__superClap--bar': type === CLAP_TYPE.BAR,
className={classNames("clappe__superClap", {
"clappe__superClap--disabled": this.isDisabled(),
"clappe__superClap--left": type === CLAP_TYPE.LEFT,
"clappe__superClap--footer": type === CLAP_TYPE.FOOTER,
"clappe__superClap--bar": type === CLAP_TYPE.BAR
})}
onClick={this.superClick}
>
Expand Down
16 changes: 7 additions & 9 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import 'chromereload/devonly'; // eslint-disable-line

import { Howl } from 'howler';
import { Howl } from "howler";
import {
CLAP_SOUND,
CLAP_DEFAULT_SETTINGS,
CLAP_SYNC_SETTINGS,
CLAP_LOCAL_SETTINGS,
} from './constants';
import { getNewSettings } from './helpers';
CLAP_LOCAL_SETTINGS
} from "./constants";
import { getNewSettings } from "./helpers";

let settings = { ...CLAP_DEFAULT_SETTINGS };

Expand All @@ -24,12 +22,12 @@ chrome.storage.local.get(CLAP_LOCAL_SETTINGS, updateSettings);

const playSound = type => {
const defaultSounds = {
[CLAP_SOUND.NORMAL]: chrome.runtime.getURL('sounds/clap.mp3'),
[CLAP_SOUND.SUPER]: chrome.runtime.getURL('sounds/superClap.mp3'),
[CLAP_SOUND.NORMAL]: chrome.runtime.getURL("sounds/clap.mp3"),
[CLAP_SOUND.SUPER]: chrome.runtime.getURL("sounds/superClap.mp3")
};

new Howl({
src: settings[type] || defaultSounds[type],
src: settings[type] || defaultSounds[type]
}).play();
};

Expand Down
32 changes: 16 additions & 16 deletions app/scripts/constants.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
export const CLAP_LIMIT = 50;
export const CLAP_CONTAINER_SELECTOR = 'js-actionMultirecommend';
export const CLAP_BUTTON_SELECTOR = 'js-actionMultirecommendButton';
export const CLAP_UNDO_BUTTON_SELECTOR = 'js-clapUndo';
export const CLAP_COMMENTS_SELECTOR = 'js-actionMultirecommendButton';
export const CLAP_CONTAINER_SELECTOR = "js-actionMultirecommend";
export const CLAP_BUTTON_SELECTOR = "js-actionMultirecommendButton";
export const CLAP_UNDO_BUTTON_SELECTOR = "js-clapUndo";
export const CLAP_COMMENTS_SELECTOR = "js-actionMultirecommendButton";
export const CLAP_TYPE = {
DISABLED: 'disabled',
LEFT: 'post_share_widget',
FOOTER: 'post_actions_footer',
BAR: 'post_actions_bar',
DISABLED: "disabled",
LEFT: "post_share_widget",
FOOTER: "post_actions_footer",
BAR: "post_actions_bar"
};
export const CLAP_SOUND = {
NORMAL: 'clap',
SUPER: 'superClap',
};
export const CLAP_DEFAULT_SETTINGS = {
...CLAP_SYNC_SETTINGS,
...CLAP_LOCAL_SETTINGS,
NORMAL: "clap",
SUPER: "superClap"
};
export const CLAP_SYNC_SETTINGS = {
sounds: true,
sounds: true
};
export const CLAP_LOCAL_SETTINGS = {
clap: null,
superClap: null,
superClap: null
};
export const CLAP_DEFAULT_SETTINGS = {
...CLAP_SYNC_SETTINGS,
...CLAP_LOCAL_SETTINGS
};
12 changes: 5 additions & 7 deletions app/scripts/contentscript.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import 'chromereload/devonly'; // eslint-disable-line

import Clappe from './Clappe';
import Clappe from "./Clappe";

const html = document.body.innerHTML;

function isMedium() {
return /medium/.test(document.head.getAttribute('prefix'));
return /medium/.test(document.head.getAttribute("prefix"));
}

function isUserLogged() {
const loggedRegex = /"isAuthenticated":([a-z]*)/;
return html.match(loggedRegex) && html.match(loggedRegex)[1] === 'true';
return html.match(loggedRegex) && html.match(loggedRegex)[1] === "true";
}

if (isMedium() && isUserLogged()) {
console.info(
'%c 👏 Clappe installed!',
'border: 1px solid black; color: black'
"%c 👏 Clappe installed!",
"border: 1px solid black; color: black"
);
new Clappe(html).install();
}
40 changes: 19 additions & 21 deletions app/scripts/options.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import 'chromereload/devonly'; // eslint-disable-line

import React from 'react';
import ReactDOM from 'react-dom';
import React from "react";
import ReactDOM from "react-dom";

import {
CLAP_DEFAULT_SETTINGS,
CLAP_LOCAL_SETTINGS,
CLAP_SYNC_SETTINGS,
} from './constants';
import { getNewSettings } from './helpers';
CLAP_SYNC_SETTINGS
} from "./constants";
import { getNewSettings } from "./helpers";

class File extends React.PureComponent {
removeSound = () => this.props.removeSound(this.props.id);
Expand Down Expand Up @@ -64,7 +62,7 @@ class Options extends React.Component {
const sounds = e.target.checked;

chrome.storage.sync.set({
sounds,
sounds
});
};

Expand All @@ -74,14 +72,14 @@ class Options extends React.Component {
reader.readAsDataURL(file);
reader.onload = () => {
chrome.storage.local.set({
[placeholder]: reader.result,
[placeholder]: reader.result
});
};
};

removeSound = placeholder => {
chrome.storage.local.set({
[placeholder]: null,
[placeholder]: null
});
};

Expand All @@ -92,7 +90,7 @@ class Options extends React.Component {
<div className="settings">
<h2>Misc</h2>
<div className="settings__item">
<label htmlFor={'sounds'}>
<label htmlFor={"sounds"}>
<input
id="sounds"
type="checkbox"
Expand All @@ -105,15 +103,15 @@ class Options extends React.Component {
<h2>Custom sounds</h2>
{[
{
name: 'Clap',
id: 'clap',
file: clap,
name: "Clap",
id: "clap",
file: clap
},
{
name: 'Super clap',
id: 'superClap',
file: superClap,
},
name: "Super clap",
id: "superClap",
file: superClap
}
].map(({ name, id, file }) => (
<div key={id} className="settings__item">
<File
Expand All @@ -126,14 +124,14 @@ class Options extends React.Component {
</div>
))}
<footer>
{'Built with ❤️ by '}
{"Built with ❤️ by "}
<a href="https://jukben.cz">jukben</a>
{'. Licensed under MIT. Code on '}
{". Licensed under MIT. Code on "}
<a href="https://github.com/jukben/clappe">GitHub</a>.
</footer>
</div>
);
}
}

ReactDOM.render(<Options />, document.getElementById('options'));
ReactDOM.render(<Options />, document.getElementById("options"));
53 changes: 53 additions & 0 deletions app/styles/contentscript.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.js-actionMultirecommend {
position: relative;
}
.js-actionMultirecommend:hover .clappe > .clappe__superClap {
opacity: 1;
}
.js-actionMultirecommend:hover .clappe > .clappe__superClap--disabled {
opacity: 0;
transform: translate(0, 0) scale(0);
}
.js-actionMultirecommend:hover .clappe > .clappe__superClap--footer {
transform: translate(-40px, -40px) scale(1);
}
.js-actionMultirecommend:hover .clappe > .clappe__superClap--left {
transform: translate(40px, -40px) scale(1);
}
.js-actionMultirecommend:hover .clappe > .clappe__superClap--bar {
transform: translate(-43px, 8px) scale(1);
}

.clappe {
position: absolute;
bottom: 0;
width: 60px;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
}

.clappe__superClap {
opacity: 0;
outline: none;
line-height: 40px;
width: 40px;
height: 40px;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 999em;
text-align: center;
transition: 0.2s all;
transform: translate(0, 0) scale(0);
}
.clappe__superClap--bar {
line-height: 25px;
font-size: 12px;
width: 25px;
height: 25px;
transform: translate(-15px, 8px) scale(0);
}
.clappe__superClap:hover {
cursor: pointer;
border-color: #00ab6b;
}
Loading

0 comments on commit 5b17e11

Please sign in to comment.