0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-10 09:12:39 +00:00

linting and space issues

This commit is contained in:
Víctor Losada Hernández
2024-01-23 08:07:51 +01:00
parent 7951c4a03a
commit 0dff59d793
2 changed files with 158 additions and 119 deletions

View File

@@ -7,7 +7,6 @@ const Moment = require('moment');
const Nav = require('naturalcrit/nav/nav.jsx'); const Nav = require('naturalcrit/nav/nav.jsx');
const Navbar = require('../../navbar/navbar.jsx'); const Navbar = require('../../navbar/navbar.jsx');
const RecentNavItem = require('../../navbar/recent.navitem.jsx').both; const RecentNavItem = require('../../navbar/recent.navitem.jsx').both;
const Account = require('../../navbar/account.navitem.jsx'); const Account = require('../../navbar/account.navitem.jsx');
const NewBrew = require('../../navbar/newbrew.navitem.jsx'); const NewBrew = require('../../navbar/newbrew.navitem.jsx');
@@ -16,28 +15,29 @@ const HelpNavItem = require('../../navbar/help.navitem.jsx');
const request = require('superagent'); const request = require('superagent');
const ArchivePage = createClass({ const ArchivePage = createClass({
displayName : 'ArchivePage', displayName: 'ArchivePage',
getDefaultProps : function() { getDefaultProps: function () {
return {}; return {};
}, },
getInitialState : function() { getInitialState: function () {
return { return {
query : '', query : '',
foundBrews : null, foundBrews : null,
searching : false, searching : false,
error : null error : null,
}; };
}, },
handleChange(e){ handleChange(e) {
this.setState({ query: e.target.value }); this.setState({ query: e.target.value });
}, },
lookup(){ lookup() {
this.setState({ searching: true, error: null }); this.setState({ searching: true, error: null });
request.get(`/admin/archive/${this.state.query}`) request
.then((res)=>this.setState({ foundBrews: res.body })) .get(`/admin/archive/${this.state.query}`)
.catch((err)=>this.setState({ error: err })) .then((res) => this.setState({ foundBrews: res.body }))
.finally(()=>this.setState({ searching: false })); .catch((err) => this.setState({ error: err }))
.finally(() => this.setState({ searching: false }));
}, },
renderFoundBrews() { renderFoundBrews() {
const brews = this.state.foundBrews; const brews = this.state.foundBrews;
@@ -58,7 +58,11 @@ const ArchivePage = createClass({
<dd> <dd>
{brew.authors.map((author, index) => ( {brew.authors.map((author, index) => (
<span key={index}> <span key={index}>
<a href={`/user/${author}`} target='_blank' rel='noopener noreferrer'> <a
href={`/user/${author}`}
target='_blank'
rel='noopener noreferrer'
>
{author} {author}
</a> </a>
{index < brew.authors.length - 1 && ', '} {index < brew.authors.length - 1 && ', '}
@@ -66,12 +70,38 @@ const ArchivePage = createClass({
))} ))}
</dd> </dd>
<a href={`/share/${brew.shareId}`}>Check the brew</a> <a href={`/share/${brew.shareId}`}>
Check the brew <i className='fas fa-external-link-alt'></i>
</a>
<dt>Last Updated</dt> <dt>Systems:</dt>
<dd>{brew.systems.join(', ')}</dd>
{brew.tags?.length ? (
<>
<div
className='brewTags'
title={`Tags:\n${brew.tags.join('\n')}`}
>
<i className='fas fa-tags' />
{brew.tags.map((tag, idx) => {
const matches = tag.match(/^(?:([^:]+):)?([^:]+)$/);
return (
<span key={idx} className={matches[1]}>
{matches[2]}
</span>
);
})}
</div>
</>
) : (
<></>
)}
<dt>Last Updated:</dt>
<dd>{Moment(brew.updatedAt).fromNow()}</dd> <dd>{Moment(brew.updatedAt).fromNow()}</dd>
<dt>Num of Views</dt> <dt>Num of Views:</dt>
<dd>{brew.views}</dd> <dd>{brew.views}</dd>
</dl> </dl>
</div> </div>
@@ -80,39 +110,50 @@ const ArchivePage = createClass({
); );
}, },
renderForm: function() { renderForm: function () {
return <div className='brewLookup'> return (
<div className='brewLookup'>
<h2>Brew Lookup</h2> <h2>Brew Lookup</h2>
<label>Title of the brew</label><input type='text' value={this.state.query} onChange={this.handleChange} placeholder='v3 Reference Document'/> <label>Title of the brew</label>
<input
type='text'
value={this.state.query}
onChange={this.handleChange}
placeholder='v3 Reference Document'
/>
{/* In the future, we should be able to filter the results by adding tags. {/* In the future, we should be able to filter the results by adding tags.
<label>Tags</label><input type="text" value={this.state.query} placeholder='add a tag to filter'/> <label>Tags</label><input type='text' value={this.state.query} placeholder='add a tag to filter'/>
*/} */}
<button onClick={this.lookup}> <button onClick={this.lookup}>
<i className={cx('fas', { <i
'fa-search' : !this.state.searching, className={cx('fas', {
'fa-spin fa-spinner' : this.state.searching, 'fa-search': !this.state.searching,
})} /> 'fa-spin fa-spinner': this.state.searching,
})}
/>
</button> </button>
</div>; </div>
);
}, },
renderResults : function() { renderResults: function () {},
}, renderNavItems: function () {
return (
renderNavItems : function() { <Navbar>
return <Navbar>
<Nav.section> <Nav.section>
<NewBrew /> <NewBrew />
<HelpNavItem /> <HelpNavItem />
<RecentNavItem /> <RecentNavItem />
<Account /> <Account />
</Nav.section> </Nav.section>
</Navbar>; </Navbar>
);
}, },
render : function() { render: function () {
return <div className='archivePage'> return (
<div className='archivePage'>
{this.renderNavItems()} {this.renderNavItems()}
<div className='content'> <div className='content'>
@@ -120,20 +161,18 @@ const ArchivePage = createClass({
<h1>Welcome to the Archive</h1> <h1>Welcome to the Archive</h1>
</div> </div>
<div className='flexGroup'> <div className='flexGroup'>
<div className='form dataGroup'> <div className='form dataGroup'>{this.renderForm()}</div>
{this.renderForm()}
</div>
<div className='resultsContainer dataGroup'> <div className='resultsContainer dataGroup'>
<div className='title'> <div className='title'>
<h2>Your results, my lordship</h2> <h2>Your results, my lordship</h2>
</div> </div>
{this.renderFoundBrews()} {this.renderFoundBrews()}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
} );
},
}); });
module.exports = ArchivePage; module.exports = ArchivePage;

View File

@@ -83,7 +83,7 @@
.brewItem { .brewItem {
background-image: url('/assets/parchmentBackground.jpg'); background-image: url('/assets/parchmentBackground.jpg');
width:500px; width:450px;
height:auto; height:auto;
min-height:unset; min-height:unset;
overflow:visible; overflow:visible;