-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from resonatecoop/new-website-search
Add search component to new website * Removes gulp and replace with hugo pipes (css, js, images)
- Loading branch information
Showing
190 changed files
with
5,119 additions
and
21,267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,14 +22,14 @@ npm install gulp-cli --global | |
|
||
```sh | ||
cd src && \ | ||
npm install && \ | ||
gulp | ||
npm install -g @babel/cli @babel/core [email protected] [email protected] && \ | ||
npm install | ||
``` | ||
|
||
### Server | ||
|
||
```sh | ||
hugo server --baseURL http://localhost:1314 --port 1314 | ||
hugo server --baseURL http://localhost:1314 --environment development --port 1314 | ||
``` | ||
|
||
## Docker | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,15 +29,13 @@ ENV NODE_ENV development | |
|
||
WORKDIR /build/website/src | ||
|
||
RUN npm install -g @babel/cli @babel/core [email protected] [email protected] | ||
RUN npm install | ||
RUN npm install -g gulp | ||
|
||
ARG NODE_ENV | ||
ENV NODE_ENV=$NODE_ENV | ||
|
||
RUN gulp | ||
|
||
RUN hugo -d ./public | ||
RUN hugo -d ./public -e ${NODE_ENV} | ||
|
||
FROM alpine:latest | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@import '@resonate/tachyons'; | ||
@import 'assets/css/_variables'; | ||
@import 'assets/css/_typography'; | ||
@import 'assets/css/_fills'; | ||
@import 'assets/css/_code'; | ||
@import 'assets/css/_hugo-internal-templates'; | ||
@import 'assets/css/_social-icons'; | ||
@import 'assets/css/_styles'; | ||
@import 'assets/css/_syntax'; | ||
|
||
@import 'assets/css/_forms'; | ||
@import 'assets/css/_buttons'; | ||
@import 'assets/css/_grid'; | ||
@import 'assets/css/_header'; | ||
@import 'assets/css/_footer'; | ||
@import 'assets/css/_nav'; | ||
|
||
@import '@resonate/search-component/index.css'; | ||
|
||
@import 'assets/css/_marketing'; | ||
@import 'assets/css/_manifesto'; |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import 'regenerator-runtime/runtime.js' | ||
import Nanocomponent from 'nanocomponent' | ||
import nanostate from 'nanostate' | ||
import choo from 'nanochoo' // resonatecoop/nanochoo (fork of nanochoo with added support for cached components) | ||
import html from 'nanohtml' | ||
import icon from '@resonate/icon-element' | ||
import Search from '@resonate/search-component' | ||
|
||
import './tabbing.js' | ||
|
||
document.addEventListener('DOMContentLoaded', DOMContentLoaded) | ||
|
||
function DOMContentLoaded () { | ||
// nav() | ||
search('.search') | ||
} | ||
|
||
// Search outer | ||
class SearchOuter extends Nanocomponent { | ||
constructor (id, state, emit) { | ||
super(id) | ||
|
||
this.state = state | ||
this.emit = emit | ||
this.local = state.components[id] = {} | ||
|
||
this.local.tags = [ | ||
'ambient', | ||
'acoustic', | ||
'alternative', | ||
'electro', | ||
'electronic', | ||
'experimental', | ||
'folk', | ||
'funk', | ||
'hiphop', | ||
'house', | ||
'indie', | ||
'instrumental', | ||
'jazz', | ||
'metal', | ||
'pop', | ||
'punk' | ||
] | ||
|
||
this.local.machine = nanostate.parallel({ | ||
search: nanostate('off', { | ||
on: { toggle: 'off' }, | ||
off: { toggle: 'on' } | ||
}) | ||
}) | ||
|
||
this.local.machine.on('search:toggle', () => { | ||
this.rerender() | ||
if (this.local.machine.state.search === 'on') { | ||
const input = document.querySelector('input[type="search"]') | ||
if (input && input !== document.activeElement) input.focus() | ||
} | ||
document.body.classList.toggle('search-open', this.local.machine.state.search === 'on') | ||
}) | ||
} | ||
|
||
createElement () { | ||
const machine = { | ||
on: () => this.state.cache(Search, 'search').render({ tags: this.local.tags }), | ||
off: () => { | ||
const attrs = { | ||
onclick: (e) => { | ||
this.local.machine.emit('search:toggle') | ||
}, | ||
class: 'js bn dn db-l bg-transparent' | ||
} | ||
return html` | ||
<button ${attrs}> | ||
<div class="flex items-center"> | ||
${icon('search', { size: 'sm' })} | ||
<span class="db pl3 near-black near-black--light near-white--dark">Search</span> | ||
</div> | ||
</button> | ||
` | ||
} | ||
}[this.local.machine.state.search] | ||
|
||
return html` | ||
<div class="search flex-l flex-auto-l w-100-l justify-center-l"> | ||
${machine()} | ||
</div> | ||
` | ||
} | ||
|
||
update () { | ||
return false | ||
} | ||
} | ||
|
||
function search (selector) { | ||
if (!document.querySelector(selector)) { | ||
console.log(`${selector} element not found`) | ||
return | ||
} | ||
|
||
const app = choo() | ||
|
||
app.use((state, emitter, app) => { | ||
state.search = state.search || { | ||
notFound: false, | ||
q: '', | ||
results: [], | ||
placeholder: 'search by name, artist, album, tag' | ||
} | ||
|
||
state.user = {} | ||
state.params = {} // nanochoo does not have a router | ||
|
||
state.cache(Search, 'search') | ||
|
||
emitter.on('search', (q) => { | ||
window.open(`https://beta.stream.resonate.coop/search?q=${q}`, '_blank') | ||
}) | ||
}) | ||
|
||
app.view((state, emit) => { | ||
return state.cache(SearchOuter, 'header').render() | ||
}) | ||
|
||
app.mount(selector) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
window.addEventListener('keydown', handleFirstTab) | ||
|
||
function handleFirstTab (e) { | ||
if (e.keyCode === 9) { | ||
document.body.classList.add('user-is-tabbing') | ||
|
||
window.removeEventListener('keydown', handleFirstTab) | ||
window.addEventListener('mousedown', handleMouseDownOnce) | ||
} | ||
} | ||
|
||
function handleMouseDownOnce () { | ||
document.body.classList.remove('user-is-tabbing') | ||
|
||
window.removeEventListener('mousedown', handleMouseDownOnce) | ||
window.addEventListener('keydown', handleFirstTab) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"*": [ | ||
"*" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
require('@babel/preset-env'), | ||
{ | ||
useBuiltIns: 'entry', | ||
corejs: 3 | ||
} | ||
] | ||
], | ||
plugins: ['module:nanohtml'] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.