Fix issues highlighted by linter

This commit is contained in:
ponas committed 2019-05-09 16:07:48 +02:00
1 parent 640c38204a
commit 24f30560e3
14 files changed
+196 -87

No files matched your search

+7 -3
View File
@@ -4,7 +4,7 @@ import { Link, graphql } from 'gatsby'
import Img from 'gatsby-image'
export default class AssociationList extends React.Component {
render_association(association) {
static renderAssociation(association) {
return (
<Link className="association" to={association.path} key={association.id}>
{association.featured_media && association.featured_media.localFile && (
@@ -32,10 +32,14 @@ export default class AssociationList extends React.Component {
return (
<section className="associations">
<h1 className="page-title">{title}</h1>
<p class="lead">Her burde det være en generell tekst om foreningene. Hva er en forening? Hvordan kan man bli med i en forening? Hva gjør foreningene? Kan jeg se alt som arrangeres av Kulturutvalget, for eksempel?</p>
<p className="lead">
Her burde det være en generell tekst om foreningene. Hva er en
forening? Hvordan kan man bli med i en forening? Hva gjør foreningene?
Kan jeg se alt som arrangeres av Kulturutvalget, for eksempel?
</p>
<div className="association-list">
{associations.map(({ node: association }) =>
this.render_association(association)
this.renderAssociation(association)
)}
</div>
</section>
+44 -31
View File
@@ -3,40 +3,12 @@ import PropTypes from 'prop-types'
import { Link, graphql } from 'gatsby'
import Img from 'gatsby-image'
import _ from 'lodash'
import moment from 'moment'
import 'moment/locale/nb'
moment.locale('nb')
export default class EventList extends React.Component {
render() {
const { events, title, onlyUpcoming, numDays, groupBy, showMore } = this.props
const filteredEvents = events.filter(({ node: event }) => {
const startTime = moment(event.start_time)
if (onlyUpcoming && !startTime.isSameOrAfter(new Date(), 'day')) {
return false
}
if (numDays) {
const lastDay = moment().add(numDays - 1, 'days')
if (!startTime.isSameOrBefore(lastDay, 'day')) {
return false
}
}
return true
})
return (
<section className="events">
{title && <h1 className="section-title">{title}</h1>}
{groupBy && this.renderEventsByDate(filteredEvents, groupBy)}
{!groupBy &&
filteredEvents.map(({ node: event }) => this.renderEvent(event))}
{showMore && <div className="show-more"><Link to="/program/" className="button">Vis alle</Link></div>}
</section>
)
}
renderEventsByDate(filteredEvents, groupBy) {
let groupByFormat = null
if (groupBy === 'day') {
@@ -77,7 +49,7 @@ export default class EventList extends React.Component {
</div>
<header className="event-header">
<span
className={`event-date $(compactDate && event-date-is-compact)`}
className={`event-date ${compactDate && 'event-date-is-compact'}`}
>
<span className="event-date-weekday">
{moment(event.start_time).format('dddd')}{' '}
@@ -119,6 +91,47 @@ export default class EventList extends React.Component {
</Link>
)
}
render() {
const {
events,
title,
onlyUpcoming,
numDays,
groupBy,
showMore,
} = this.props
const filteredEvents = events.filter(({ node: event }) => {
const startTime = moment(event.start_time)
if (onlyUpcoming && !startTime.isSameOrAfter(new Date(), 'day')) {
return false
}
if (numDays) {
const lastDay = moment().add(numDays - 1, 'days')
if (!startTime.isSameOrBefore(lastDay, 'day')) {
return false
}
}
return true
})
return (
<section className="events">
{title && <h1 className="section-title">{title}</h1>}
{groupBy && this.renderEventsByDate(filteredEvents, groupBy)}
{!groupBy &&
filteredEvents.map(({ node: event }) => this.renderEvent(event))}
{showMore && (
<div className="show-more">
<Link to="/program/" className="button">
Vis alle
</Link>
</div>
)}
</section>
)
}
}
EventList.propTypes = {
@@ -128,7 +141,7 @@ EventList.propTypes = {
numDays: PropTypes.number,
groupBy: PropTypes.string,
compactDate: PropTypes.bool,
showMore: PropTypes.bool
showMore: PropTypes.bool,
}
EventList.defaultProps = {
+60 -7
View File
@@ -11,17 +11,70 @@ const Footer = () => (
</Link>
</div>
<nav className="social-nav">
<a href="https://www.facebook.com/studentersamfundet" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="49.652" height="49.652" viewBox="0 0 49.652 49.652"><path fill="#fff" d="M24.826 0C11.137 0 0 11.137 0 24.826c0 13.688 11.137 24.826 24.826 24.826 13.688 0 24.826-11.138 24.826-24.826C49.652 11.137 38.516 0 24.826 0zM31 25.7h-4.039v14.396h-5.985V25.7h-2.845v-5.088h2.845v-3.291c0-2.357 1.12-6.04 6.04-6.04l4.435.017v4.939h-3.219c-.524 0-1.269.262-1.269 1.386v2.99h4.56L31 25.7z"></path></svg>
<a
href="https://www.facebook.com/studentersamfundet"
target="_blank"
rel="noopener noreferrer"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="49.652"
height="49.652"
viewBox="0 0 49.652 49.652"
>
<path
fill="#fff"
d="M24.826 0C11.137 0 0 11.137 0 24.826c0 13.688 11.137 24.826 24.826 24.826 13.688 0 24.826-11.138 24.826-24.826C49.652 11.137 38.516 0 24.826 0zM31 25.7h-4.039v14.396h-5.985V25.7h-2.845v-5.088h2.845v-3.291c0-2.357 1.12-6.04 6.04-6.04l4.435.017v4.939h-3.219c-.524 0-1.269.262-1.269 1.386v2.99h4.56L31 25.7z"
/>
</svg>
</a>
<a href="https://www.instagram.com/studentersamfundet/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="49.652" height="49.652" viewBox="0 0 49.652 49.652"><g fill="#fff"><path d="M24.825 29.796a4.978 4.978 0 0 0 4.972-4.97 4.954 4.954 0 0 0-.94-2.897 4.964 4.964 0 0 0-4.029-2.073c-1.659 0-3.126.82-4.031 2.072a4.947 4.947 0 0 0-.94 2.897 4.973 4.973 0 0 0 4.968 4.971zm10.853-11.05V13.96l-.623.002-4.164.013.016 4.787z"></path><path d="M24.826 0C11.137 0 0 11.137 0 24.826c0 13.688 11.137 24.826 24.826 24.826 13.688 0 24.826-11.138 24.826-24.826C49.652 11.137 38.516 0 24.826 0zm14.119 21.929v11.56a5.463 5.463 0 0 1-5.457 5.458H16.164a5.462 5.462 0 0 1-5.457-5.458V16.165a5.462 5.462 0 0 1 5.457-5.457h17.323a5.463 5.463 0 0 1 5.458 5.457v5.764z"></path><path d="M32.549 24.826c0 4.257-3.464 7.723-7.723 7.723s-7.722-3.466-7.722-7.723a7.67 7.67 0 0 1 .568-2.897h-4.215v11.56a2.706 2.706 0 0 0 2.706 2.704h17.323a2.707 2.707 0 0 0 2.706-2.704v-11.56h-4.217c.367.894.574 1.873.574 2.897z"></path></g></svg>
<a
href="https://www.instagram.com/studentersamfundet/"
target="_blank"
rel="noopener noreferrer"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="49.652"
height="49.652"
viewBox="0 0 49.652 49.652"
>
<g fill="#fff">
<path d="M24.825 29.796a4.978 4.978 0 0 0 4.972-4.97 4.954 4.954 0 0 0-.94-2.897 4.964 4.964 0 0 0-4.029-2.073c-1.659 0-3.126.82-4.031 2.072a4.947 4.947 0 0 0-.94 2.897 4.973 4.973 0 0 0 4.968 4.971zm10.853-11.05V13.96l-.623.002-4.164.013.016 4.787z" />
<path d="M24.826 0C11.137 0 0 11.137 0 24.826c0 13.688 11.137 24.826 24.826 24.826 13.688 0 24.826-11.138 24.826-24.826C49.652 11.137 38.516 0 24.826 0zm14.119 21.929v11.56a5.463 5.463 0 0 1-5.457 5.458H16.164a5.462 5.462 0 0 1-5.457-5.458V16.165a5.462 5.462 0 0 1 5.457-5.457h17.323a5.463 5.463 0 0 1 5.458 5.457v5.764z" />
<path d="M32.549 24.826c0 4.257-3.464 7.723-7.723 7.723s-7.722-3.466-7.722-7.723a7.67 7.67 0 0 1 .568-2.897h-4.215v11.56a2.706 2.706 0 0 0 2.706 2.704h17.323a2.707 2.707 0 0 0 2.706-2.704v-11.56h-4.217c.367.894.574 1.873.574 2.897z" />
</g>
</svg>
</a>
<a href="https://twitter.com/dns1813" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="49.652" height="49.652" viewBox="0 0 49.652 49.652"><path fill="#fff" d="M24.826 0C11.137 0 0 11.137 0 24.826c0 13.688 11.137 24.826 24.826 24.826 13.688 0 24.826-11.138 24.826-24.826C49.652 11.137 38.516 0 24.826 0zm11.075 19.144c.011.246.017.494.017.742 0 7.551-5.746 16.255-16.259 16.255-3.227 0-6.231-.943-8.759-2.565.447.053.902.08 1.363.08 2.678 0 5.141-.914 7.097-2.446a5.72 5.72 0 0 1-5.338-3.969 5.76 5.76 0 0 0 2.58-.096 5.715 5.715 0 0 1-4.583-5.603l.001-.072a5.69 5.69 0 0 0 2.587.714 5.71 5.71 0 0 1-2.541-4.755c0-1.048.281-2.03.773-2.874a16.225 16.225 0 0 0 11.777 5.972 5.707 5.707 0 0 1-.147-1.303 5.714 5.714 0 0 1 9.884-3.91 11.406 11.406 0 0 0 3.63-1.387 5.74 5.74 0 0 1-2.516 3.162 11.36 11.36 0 0 0 3.282-.899 11.494 11.494 0 0 1-2.848 2.954z"></path></svg>
<a
href="https://twitter.com/dns1813"
target="_blank"
rel="noopener noreferrer"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="49.652"
height="49.652"
viewBox="0 0 49.652 49.652"
>
<path
fill="#fff"
d="M24.826 0C11.137 0 0 11.137 0 24.826c0 13.688 11.137 24.826 24.826 24.826 13.688 0 24.826-11.138 24.826-24.826C49.652 11.137 38.516 0 24.826 0zm11.075 19.144c.011.246.017.494.017.742 0 7.551-5.746 16.255-16.259 16.255-3.227 0-6.231-.943-8.759-2.565.447.053.902.08 1.363.08 2.678 0 5.141-.914 7.097-2.446a5.72 5.72 0 0 1-5.338-3.969 5.76 5.76 0 0 0 2.58-.096 5.715 5.715 0 0 1-4.583-5.603l.001-.072a5.69 5.69 0 0 0 2.587.714 5.71 5.71 0 0 1-2.541-4.755c0-1.048.281-2.03.773-2.874a16.225 16.225 0 0 0 11.777 5.972 5.707 5.707 0 0 1-.147-1.303 5.714 5.714 0 0 1 9.884-3.91 11.406 11.406 0 0 0 3.63-1.387 5.74 5.74 0 0 1-2.516 3.162 11.36 11.36 0 0 0 3.282-.899 11.494 11.494 0 0 1-2.848 2.954z"
/>
</svg>
</a>
<a href="https://www.flickr.com/groups/neuf/pool/" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" width="97.75" height="97.75" viewBox="0 0 97.75 97.75"><path fill="#fff" d="M48.875 0C21.883 0 0 21.882 0 48.875S21.883 97.75 48.875 97.75 97.75 75.868 97.75 48.875 75.867 0 48.875 0zM28.277 66.361c-8.895 0-16.105-7.828-16.105-17.486s7.211-17.487 16.105-17.487 16.106 7.829 16.106 17.487-7.211 17.486-16.106 17.486zm40.731-.416c-9.152 0-16.57-7.735-16.57-17.279 0-9.542 7.418-17.278 16.57-17.278 9.15 0 16.57 7.736 16.57 17.278 0 9.544-7.42 17.279-16.57 17.279z"></path></svg>
<svg
xmlns="http://www.w3.org/2000/svg"
width="97.75"
height="97.75"
viewBox="0 0 97.75 97.75"
>
<path
fill="#fff"
d="M48.875 0C21.883 0 0 21.882 0 48.875S21.883 97.75 48.875 97.75 97.75 75.868 97.75 48.875 75.867 0 48.875 0zM28.277 66.361c-8.895 0-16.105-7.828-16.105-17.486s7.211-17.487 16.105-17.487 16.106 7.829 16.106 17.487-7.211 17.486-16.106 17.486zm40.731-.416c-9.152 0-16.57-7.735-16.57-17.279 0-9.542 7.418-17.278 16.57-17.278 9.15 0 16.57 7.736 16.57 17.278 0 9.544-7.42 17.279-16.57 17.279z"
/>
</svg>
</a>
</nav>
</div>
+5 -1
View File
@@ -1,6 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import Navbar from './Navbar'
import Footer from './Footer'
import '../css/main.scss'
@@ -14,4 +14,8 @@ const TemplateWrapper = ({ children }) => (
</div>
)
TemplateWrapper.propTypes = {
children: PropTypes.shape({}).isRequired,
}
export default TemplateWrapper
+8 -7
View File
@@ -1,6 +1,5 @@
import React from 'react'
import { Link, StaticQuery, graphql } from 'gatsby'
import github from '../img/github-icon.svg'
import { Link } from 'gatsby'
import logo from '../img/logo/logo-s.svg'
export default class Navbar extends React.Component {
@@ -8,17 +7,17 @@ export default class Navbar extends React.Component {
super(props)
this.state = {
showNav: false,
headerSize: 200
headerSize: 200,
}
this.resizeHeader = this.resizeHeader.bind(this);
this.resizeHeader = this.resizeHeader.bind(this)
}
componentDidMount() {
window.addEventListener('scroll', this.resizeHeader);
window.addEventListener('scroll', this.resizeHeader)
}
componentWillUnmount() {
window.removeEventListener('scroll', this.resizeHeader);
window.removeEventListener('scroll', this.resizeHeader)
}
toggleNav() {
@@ -38,7 +37,9 @@ export default class Navbar extends React.Component {
render() {
return (
<header
className={`site-header ${this.state.showNav ? 'site-nav-visible' : ''}`}
className={`site-header ${
this.state.showNav ? 'site-nav-visible' : ''
}`}
>
<nav className="site-nav">
<Link to="/program/">Program</Link>
+9 -3
View File
@@ -23,7 +23,7 @@ export default class PostList extends React.Component {
<div className="post-text">
<header className="post-header">
<h2 className="post-title">{post.title}</h2>
{/*<div className="post-meta">{post.date}</div>*/}
{/* <div className="post-meta">{post.date}</div> */}
</header>
<div className="post-body">
<div
@@ -37,7 +37,13 @@ export default class PostList extends React.Component {
</Link>
))}
</div>
{showMore && <div className="show-more"><Link to="/nyheter/" className="button">Vis alle</Link></div>}
{showMore && (
<div className="show-more">
<Link to="/nyheter/" className="button">
Vis alle
</Link>
</div>
)}
</section>
)
}
@@ -46,7 +52,7 @@ export default class PostList extends React.Component {
PostList.propTypes = {
posts: PropTypes.arrayOf(PropTypes.object),
title: PropTypes.string,
showMore: PropTypes.bool
showMore: PropTypes.bool,
}
export const pageQuery = graphql`
+13 -12
View File
@@ -1,18 +1,17 @@
import React from 'react'
import PropTypes from 'prop-types'
import { graphql } from 'gatsby'
import Layout from '../components/Layout'
import Img from 'gatsby-image'
import Layout from '../components/Layout'
export const AssociationTemplate = data => {
const {
title,
content,
hasFeaturedMedia,
featuredMedia,
type,
homepage,
} = data
export const AssociationTemplate = ({
title,
content,
featuredMedia,
type,
homepage,
}) => {
const hasFeaturedMedia = featuredMedia && !!featuredMedia.localFile
return (
<section className="association-page">
<h1 className="page-title">{title}</h1>
@@ -38,6 +37,9 @@ export const AssociationTemplate = data => {
AssociationTemplate.propTypes = {
title: PropTypes.string.isRequired,
content: PropTypes.string,
featuredMedia: PropTypes.shape({}),
type: PropTypes.string,
homepage: PropTypes.string,
}
const Association = ({ data }) => {
@@ -50,7 +52,6 @@ const Association = ({ data }) => {
content={association.content}
type={association.association_type}
homepage={association.association_homepage}
hasFeaturedMedia={!!association.featured_media.localFile}
featuredMedia={association.featured_media}
/>
</Layout>
@@ -58,7 +59,7 @@ const Association = ({ data }) => {
}
Association.propTypes = {
data: PropTypes.object.isRequired,
data: PropTypes.shape({}).isRequired,
}
export default Association
-3
View File
@@ -1,7 +1,4 @@
import React from 'react'
import PropTypes from 'prop-types'
import { graphql } from 'gatsby'
import { Link } from 'gatsby'
import Layout from '../components/Layout'
export default class DesignManual extends React.Component {
+1
View File
@@ -24,6 +24,7 @@ EventTypeProgram.propTypes = {
edges: PropTypes.array,
}),
}),
pageContext: PropTypes.shape({}),
}
export const pageQuery = graphql`
+8 -2
View File
@@ -47,7 +47,8 @@ export const EventTemplate = ({
{venueCustom && <span>{venueCustom}</span>}
{venue && venue.title !== 'Hele huset' && (
<span>
{venue.preposition} <Link to={venue.path}>{venue.title}</Link>
{venue.preposition}{' '}
<Link to={venue.path}>{venue.title}</Link>
</span>
)}
{venue && venue.title === 'Hele huset' && (
@@ -102,7 +103,12 @@ export const EventTemplate = ({
</div>
<div className="event-links">
{ticketUrl && (
<a className="event-link ticket-url" href={ticketUrl} target="_blank">
<a
className="event-link ticket-url"
href={ticketUrl}
target="_blank"
rel="noopener noreferrer"
>
<span>Kjøp billetter</span>
</a>
)}
+27 -10
View File
@@ -1,12 +1,10 @@
import React from 'react'
import PropTypes from 'prop-types'
import { graphql } from 'gatsby'
import { Link } from 'gatsby'
import { graphql, Link } from 'gatsby'
import Layout from '../components/Layout'
import PostList from '../components/PostList'
import EventList from '../components/EventList'
export default class IndexPage extends React.Component {
render() {
const { data } = this.props
@@ -15,11 +13,26 @@ export default class IndexPage extends React.Component {
return (
<Layout>
<EventList events={events} numDays={7} groupBy="day" title="Dette skjer" showMore />
<EventList
events={events}
numDays={7}
groupBy="day"
title="Dette skjer"
showMore
/>
<section className="volunteer">
<Link to="/bli-aktiv/" className="section-title">Bli frivillig</Link>
<p>Vil du være med å arrangere greier på studentersamfundet? Sjekk ut de ulike <Link to="/bli-aktiv/">foreningene</Link> som holder til på Chateau Neuf.</p>
<p>Vi trenger alltid flere engasjerte folk! Her er noen eksempler på roller du kan innta:</p>
<Link to="/bli-aktiv/" className="section-title">
Bli frivillig
</Link>
<p>
Vil du være med å arrangere greier på studentersamfundet? Sjekk ut
de ulike <Link to="/bli-aktiv/">foreningene</Link> som holder til på
Chateau Neuf.
</p>
<p>
Vi trenger alltid flere engasjerte folk! Her er noen eksempler på
roller du kan innta:
</p>
<ul>
<li>Økonomiansvarlig</li>
<li>Skuespiller</li>
@@ -32,9 +45,13 @@ export default class IndexPage extends React.Component {
<div className="address">
<h2>Besøk oss</h2>
<p>Vi holder til på Majorstua. Finn veibeskrivelse under.</p>
<label for="directions">Jeg vil reise fra:</label>
<input type="text" name="directions" placeholder="Skriv inn adresse" />
<label htmlFor="directions">Jeg vil reise fra:</label>
<input
type="text"
id="directions"
name="directions"
placeholder="Skriv inn adresse"
/>
</div>
<div className="opening-hours">
<h2>Åpningstider</h2>
+1 -1
View File
@@ -31,7 +31,7 @@ const Page = ({ data }) => {
}
Page.propTypes = {
data: PropTypes.object.isRequired,
data: PropTypes.shape({}).isRequired,
}
export default Page
+10 -4
View File
@@ -2,17 +2,17 @@ import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import { graphql, Link } from 'gatsby'
import Layout from '../components/Layout'
import Img from 'gatsby-image'
import moment from 'moment'
import 'moment/locale/nb'
import Layout from '../components/Layout'
moment.locale('nb')
export const BlogPostTemplate = ({
content,
categories,
tags,
// categories,
// tags,
title,
date,
author,
@@ -52,6 +52,12 @@ export const BlogPostTemplate = ({
BlogPostTemplate.propTypes = {
content: PropTypes.node.isRequired,
title: PropTypes.string,
date: PropTypes.string.isRequired,
featuredMedia: PropTypes.shape({}),
author: PropTypes.shape({
name: PropTypes.string,
slug: PropTypes.string,
}),
}
const BlogPost = ({ data }) => {
+3 -3
View File
@@ -1,8 +1,8 @@
import React from 'react'
import PropTypes from 'prop-types'
import { graphql } from 'gatsby'
import Layout from '../components/Layout'
import Img from 'gatsby-image'
import Layout from '../components/Layout'
export class VenueTemplate extends React.Component {
render() {
@@ -61,7 +61,7 @@ export class VenueTemplate extends React.Component {
VenueTemplate.propTypes = {
title: PropTypes.string.isRequired,
content: PropTypes.string,
featuredImage: PropTypes.object,
featuredMedia: PropTypes.shape({}),
floor: PropTypes.string,
capacityLegal: PropTypes.string,
capacityStanding: PropTypes.string,
@@ -97,7 +97,7 @@ const VenuePage = ({ data }) => {
}
VenuePage.propTypes = {
data: PropTypes.object.isRequired,
data: PropTypes.shape({}).isRequired,
}
export default VenuePage