From 0dff59d793ec4b33a85e1b7babfef5fd901c1576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Tue, 23 Jan 2024 08:07:51 +0100 Subject: [PATCH] linting and space issues --- .../pages/archivePage/archivePage.jsx | 275 ++++++++++-------- .../pages/archivePage/archivePage.less | 2 +- 2 files changed, 158 insertions(+), 119 deletions(-) diff --git a/client/homebrew/pages/archivePage/archivePage.jsx b/client/homebrew/pages/archivePage/archivePage.jsx index 7a5da8916..9926de3a8 100644 --- a/client/homebrew/pages/archivePage/archivePage.jsx +++ b/client/homebrew/pages/archivePage/archivePage.jsx @@ -1,139 +1,178 @@ require('./archivePage.less'); -const React = require('react'); +const React = require('react'); const createClass = require('create-react-class'); -const _ = require('lodash'); -const cx = require('classnames'); -const Moment = require('moment'); - -const Nav = require('naturalcrit/nav/nav.jsx'); -const Navbar = require('../../navbar/navbar.jsx'); +const _ = require('lodash'); +const cx = require('classnames'); +const Moment = require('moment'); +const Nav = require('naturalcrit/nav/nav.jsx'); +const Navbar = require('../../navbar/navbar.jsx'); const RecentNavItem = require('../../navbar/recent.navitem.jsx').both; -const Account = require('../../navbar/account.navitem.jsx'); -const NewBrew = require('../../navbar/newbrew.navitem.jsx'); -const HelpNavItem = require('../../navbar/help.navitem.jsx'); +const Account = require('../../navbar/account.navitem.jsx'); +const NewBrew = require('../../navbar/newbrew.navitem.jsx'); +const HelpNavItem = require('../../navbar/help.navitem.jsx'); const request = require('superagent'); const ArchivePage = createClass({ - displayName : 'ArchivePage', - getDefaultProps : function() { - return {}; - }, - getInitialState : function() { - return { - query : '', - foundBrews : null, - searching : false, - error : null - }; - }, - handleChange(e){ - this.setState({ query: e.target.value }); - }, - lookup(){ - this.setState({ searching: true, error: null }); + displayName: 'ArchivePage', + getDefaultProps: function () { + return {}; + }, + getInitialState: function () { + return { + query : '', + foundBrews : null, + searching : false, + error : null, + }; + }, + handleChange(e) { + this.setState({ query: e.target.value }); + }, + lookup() { + this.setState({ searching: true, error: null }); - request.get(`/admin/archive/${this.state.query}`) - .then((res)=>this.setState({ foundBrews: res.body })) - .catch((err)=>this.setState({ error: err })) - .finally(()=>this.setState({ searching: false })); - }, - renderFoundBrews() { - const brews = this.state.foundBrews; - - if (!brews || brews.length === 0) { - return
No brews found.
; - } - - return ( -
- {brews.map((brew, index) => ( -
-
-
Title:
-
{brew.title}
- -
Authors:
-
- {brew.authors.map((author, index) => ( - - - {author} - - {index < brew.authors.length - 1 && ', '} + request + .get(`/admin/archive/${this.state.query}`) + .then((res) => this.setState({ foundBrews: res.body })) + .catch((err) => this.setState({ error: err })) + .finally(() => this.setState({ searching: false })); + }, + renderFoundBrews() { + const brews = this.state.foundBrews; + + if (!brews || brews.length === 0) { + return
No brews found.
; + } + + return ( +
+ {brews.map((brew, index) => ( +
+
+
Title:
+
{brew.title}
+ +
Authors:
+
+ {brew.authors.map((author, index) => ( + + + {author} + + {index < brew.authors.length - 1 && ', '} + + ))} +
+ + + Check the brew + + +
Systems:
+
{brew.systems.join(', ')}
+ + {brew.tags?.length ? ( + <> +
+ + {brew.tags.map((tag, idx) => { + const matches = tag.match(/^(?:([^:]+):)?([^:]+)$/); + return ( + + {matches[2]} - ))} -
- - Check the brew - -
Last Updated
-
{Moment(brew.updatedAt).fromNow()}
- -
Num of Views
-
{brew.views}
-
-
- ))} + ); + })} +
+ + ) : ( + <> + )} + +
Last Updated:
+
{Moment(brew.updatedAt).fromNow()}
+ +
Num of Views:
+
{brew.views}
+ - ); - }, + ))} + + ); + }, - renderForm: function() { - return
-

Brew Lookup

- - {/* In the future, we should be able to filter the results by adding tags. - + renderForm: function () { + return ( +
+

Brew Lookup

+ + + {/* In the future, we should be able to filter the results by adding tags. + */} - -
; - }, + +
+ ); + }, - renderResults : function() { + renderResults: function () {}, - }, - - renderNavItems : function() { - return - - - - - - - ; - }, + renderNavItems: function () { + return ( + + + + + + + + + ); + }, - render : function() { - return
- {this.renderNavItems()} + render: function () { + return ( +
+ {this.renderNavItems()} -
-
-

Welcome to the Archive

-
-
-
- {this.renderForm()} -
-
-
-

Your results, my lordship

- -
- {this.renderFoundBrews()} -
-
+
+
+

Welcome to the Archive

+
+
+
{this.renderForm()}
+
+
+

Your results, my lordship

+
+ {this.renderFoundBrews()}
+
- } +
+ ); + }, }); -module.exports = ArchivePage; \ No newline at end of file +module.exports = ArchivePage; diff --git a/client/homebrew/pages/archivePage/archivePage.less b/client/homebrew/pages/archivePage/archivePage.less index f4cc75ab1..08b10d86d 100644 --- a/client/homebrew/pages/archivePage/archivePage.less +++ b/client/homebrew/pages/archivePage/archivePage.less @@ -83,7 +83,7 @@ .brewItem { background-image: url('/assets/parchmentBackground.jpg'); - width:500px; + width:450px; height:auto; min-height:unset; overflow:visible;