mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-24 02:27:37 +00:00
Make logo clickable
This commit is contained in:
parent
0cb472e676
commit
e083150e33
4 changed files with 24 additions and 12 deletions
14
src/App.js
14
src/App.js
|
|
@ -129,7 +129,19 @@ class App extends React.Component {
|
|||
return (
|
||||
<div>
|
||||
<div id="search">
|
||||
<h1>{"🌩️"}</h1>
|
||||
<h1>
|
||||
<a
|
||||
href="/"
|
||||
onClick={e => {
|
||||
if (Utils.eventIsLinkClick(e)) {
|
||||
e.preventDefault();
|
||||
this.props.setSearchQuery(null);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{"🌩️"}
|
||||
</a>
|
||||
</h1>
|
||||
<input
|
||||
type="text"
|
||||
onChange={e => this.props.setSearchQuery(e.target.value)}
|
||||
|
|
|
|||
10
src/Skin.js
10
src/Skin.js
|
|
@ -1,10 +1,6 @@
|
|||
import React from "react";
|
||||
import * as Utils from "./utils";
|
||||
|
||||
function isModifiedEvent(event) {
|
||||
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
||||
}
|
||||
|
||||
export default class Skin extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
|
@ -45,11 +41,7 @@ export default class Skin extends React.Component {
|
|||
cursor: "pointer"
|
||||
}}
|
||||
onClick={e => {
|
||||
if (
|
||||
!e.defaultPrevented && // onClick prevented default
|
||||
e.button === 0 && // ignore everything but left clicks
|
||||
!isModifiedEvent(e) // ignore clicks with modifier keys
|
||||
) {
|
||||
if (Utils.eventIsLinkClick(e)) {
|
||||
e.preventDefault();
|
||||
const { top, left } = this._ref.getBoundingClientRect();
|
||||
this.props.selectSkin(this.props.hash, { top, left });
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ const searchEpic = actions =>
|
|||
actions.pipe(
|
||||
filter(action => action.type === "SEARCH_QUERY_CHANGED"),
|
||||
switchMap(({ query }) => {
|
||||
if (query.length === 0) {
|
||||
if (query == null || query.length === 0) {
|
||||
return of(Actions.gotNewMatchingHashes(null));
|
||||
}
|
||||
|
||||
|
|
|
|||
10
src/utils.js
10
src/utils.js
|
|
@ -13,7 +13,7 @@ export function skinUrlFromHash(hash) {
|
|||
}
|
||||
|
||||
export function getPermalinkUrlFromHash(hash) {
|
||||
return `/skin/${hash}/${filenameFromHash(hash)}/`;
|
||||
return `/skin/${hash}/${filenameFromHash(hash)}`;
|
||||
}
|
||||
|
||||
export function getWindowSize() {
|
||||
|
|
@ -29,3 +29,11 @@ export function getWindowSize() {
|
|||
windowHeight: y
|
||||
};
|
||||
}
|
||||
|
||||
export function eventIsLinkClick(event) {
|
||||
return (
|
||||
!event.defaultPrevented && // onClick prevented default
|
||||
event.button === 0 &&
|
||||
!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue