Skip to content

Commit

Permalink
Merge pull request #313 from FuelRats/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleClapton authored Mar 10, 2021
2 parents ddf9e5b + 36c5534 commit 0ea04b0
Show file tree
Hide file tree
Showing 26 changed files with 492 additions and 87 deletions.
10 changes: 7 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
!.*

# Compiled sources
dist
deploy_dist
node_modules
.github
.vscode/blueprints
.yarn
deploy_dist
dist
docs
node_modules
public
scripts
8 changes: 7 additions & 1 deletion .stylelintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
dist
.github
.vscode
.yarn
deploy_dist
dist
docs
node_modules
public
scripts
**/*.js
**/*.mjs
**/*.json
Expand Down
3 changes: 3 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
extends: '@fuelrats/stylelint-config',
rules: {
'media-query-list-comma-space-after': 'always-single-line',
},
}
20 changes: 13 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
},
},
"[javascriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": true,
},
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[scss]": {
"editor.defaultFormatter": "stylelint.vscode-stylelint",
"editor.codeActionsOnSave": {
"source.fixAll.stylelint": true
},
"editor.defaultFormatter": "stylelint.vscode-stylelint"
}
},
"blueprint.templatesPath": [
"./.vscode/blueprints"
Expand All @@ -22,14 +28,14 @@
],
"editor.tabSize": 2,
"editor.wordWrapColumn": 180,
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"eslint.packageManager": "yarn",
"files.associations": {
"*.js": "javascriptreact",
"*.mjs": "javascript",
".all-contributorsrc": "json",
".stylelintrc": "json"
".stylelintrc": "json",
"yarn.lock": "yaml",
},
"files.eol": "\n",
"files.insertFinalNewline": true,
Expand All @@ -54,5 +60,5 @@
},
"stylelint.packageManager": "yarn",
"stylelint.reportNeedlessDisables": true,
"cSpell.language": "en,en-US"
"cSpell.language": "en,en-US",
}
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,25 @@ For detailed rules of this file, see [Changelog Rules](#changelog-rules)


[#303]: https://github.com/fuelRats/fuelrats.com/pull/303
[Unreleased]: https://github.com/FuelRats/fuelrats.com/compare/v2.12.8...HEAD
[Unreleased]: https://github.com/FuelRats/fuelrats.com/compare/v2.12.9...HEAD





## [2.12.9][] - 2021-03-10

### ✨ Added
* Add asterisk icon to inputs when they are required, but empty. - [#312][]


### ⚡ Changed
* Tightened security on donation session creation (again) - [#312][]
* Move fuelrats API routes to `/api/fr` to free up the api directory for other things. - [#312][]


[#312]: https://github.com/fuelRats/fuelrats.com/pull/312
[2.12.9]: https://github.com/FuelRats/fuelrats.com/compare/v2.12.8...v2.12.9



Expand Down
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {
},
apis: {
fuelRats: {
local: `${FINAL_PUBLIC_URL}/api`,
local: `${FINAL_PUBLIC_URL}/api/fr`,
server: FRDC_API_URL || 'http://localhost:8080',
socket: FRDC_SOCKET_URL || 'wss://localhost:8080',
},
Expand Down
Binary file added public/static/images/100k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions src/components/AuthDependantLink.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Link from 'next/link'
import PropTypes from 'prop-types'
import { useSelector } from 'react-redux'

import { selectCurrentUserId } from '~/store/selectors'

/**
* Links to a different page or external URL dependant on the user's login state.
* @param {*} props React Props
* @returns {Element}
*/
function AuthDependantLink (props) {
const {
children,
elseExternal,
elseHref,
external,
href,
} = props

const userId = useSelector(selectCurrentUserId)

const destination = userId ? href : elseHref

if ((userId && external) || (!userId && elseExternal)) {
return (
<a href={destination}>
{children}
</a>
)
}

return (
<Link href={destination}>
<a>
{children}
</a>
</Link>
)
}


AuthDependantLink.propTypes = {
children: PropTypes.node,
elseExternal: PropTypes.bool,
elseHref: PropTypes.string.isRequired,
external: PropTypes.bool,
href: PropTypes.string.isRequired,
}


export default AuthDependantLink
4 changes: 4 additions & 0 deletions src/components/DonateForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PropTypes from 'prop-types'
import React from 'react'
import { createStructuredSelector } from 'reselect'

import getFingerprint from '~/helpers/getFingerprint'
import getMoney from '~/helpers/getMoney'
import { connect } from '~/store'
import { withCurrentUserId, selectUserById } from '~/store/selectors'
Expand Down Expand Up @@ -130,9 +131,12 @@ class DonateForm extends React.Component {
currency,
} = this.state

const fingerprint = await getFingerprint()

const sessionData = {
amount: this.stripeAmount,
currency,
fingerprint,
}

if (user) {
Expand Down
6 changes: 4 additions & 2 deletions src/components/Fieldsets/InputFieldset/InputFieldset.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const InputFieldset = React.forwardRef((props, forwardRef) => {
handleChange,
} = useField(props.name, { onValidate: handleValidate, onChange, validateOpts })

const hideMessages = !messages?.validatedValue?.length || !messages?.hasMessages || validating || !isFocused

return (
<fieldset>

Expand All @@ -109,12 +111,12 @@ const InputFieldset = React.forwardRef((props, forwardRef) => {
onFocus={onFocus} />
{children}
<ValidityIcon
className={{ [styles.hidden]: !value.length }}
hasMessages={messages?.hasMessages}
required={props.required && !value.length}
valid={messages?.valid}
validating={validating} />
<InputSuggestions
className={{ dark, [styles.hidden]: !messages?.validatedValue?.length || !messages?.hasMessages || validating || !isFocused }}
className={{ dark, [styles.hidden]: hideMessages }}
messages={messages} />
</div>
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
.validityIconGroup {
composes: validityIconGroup from global;

pointer-events: none;

position: absolute;
top: 1px;
right: 1px;
Expand Down
82 changes: 56 additions & 26 deletions src/components/Fieldsets/InputFieldset/ValidityIcon.js
Original file line number Diff line number Diff line change
@@ -1,63 +1,93 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import PropTypes from 'prop-types'
import { useMemo } from 'react'

import styles from './InputFieldset.module.scss'





/**
*
* @param {*} props component props
* @param {boolean} props.required When the input is invalid, should the required asterisk be displayed.
* @returns {Element}
*/
function ValidityIcon (props) {
const {
className,
hasMessages,
invalidTitle = 'This input is invalid',
required,
requiredTitle = 'This input is required',
valid,
validating,
hasMessages,
validatingTitle = 'validating...',
validTitle = 'This input is valid!',
validWithMessageTitle = 'This input is valid, however something may be improved.',
...restProps
} = props

const iconProps = {
...restProps,
icon: 'check',
title: 'This input is valid!',
}

if (validating) {
iconProps.icon = 'sync'
iconProps.spin = true
iconProps.title = 'validating...'
} else if (!valid) {
iconProps.icon = 'exclamation-triangle'
iconProps.title = 'This input is invalid'
} else if (hasMessages) {
iconProps.title = 'This input is valid, however something may be improved.'
}

const iconProps = useMemo(() => {
const nextProps = {
icon: 'check',
title: validTitle,
}

if (validating) {
nextProps.icon = 'sync'
nextProps.spin = true
nextProps.title = validatingTitle
} else if (!valid) {
if (required) {
nextProps.icon = 'asterisk'
nextProps.title = requiredTitle
} else {
nextProps.icon = 'exclamation-triangle'
nextProps.title = invalidTitle
}
} else if (hasMessages) {
nextProps.title = validWithMessageTitle
}

return nextProps
}, [hasMessages, invalidTitle, required, requiredTitle, valid, validTitle, validWithMessageTitle, validating, validatingTitle])



return (
<div className={[styles.validityIconGroup, className]}>
<FontAwesomeIcon
{...restProps}
{...iconProps}
fixedWidth
className={[styles.validityIcon, { [styles.valid]: valid && !validating }]} />

{
Boolean(valid && hasMessages) && (
<FontAwesomeIcon
fixedWidth
className={[styles.warningIcon, className]}
icon="exclamation-circle"
title="This input is valid, however something may be improved." />
)
}
Boolean(valid && hasMessages) && (
<FontAwesomeIcon
fixedWidth
className={[styles.warningIcon, className]}
icon="exclamation-circle"
title={validWithMessageTitle} />
)
}
</div>
)
}

ValidityIcon.propTypes = {
className: PropTypes.string,
hasMessages: PropTypes.any,
invalidTitle: PropTypes.string,
required: PropTypes.bool,
requiredTitle: PropTypes.string,
valid: PropTypes.any,
validating: PropTypes.any,
validatingTitle: PropTypes.string,
validTitle: PropTypes.string,
validWithMessageTitle: PropTypes.string,
}


Expand Down
Loading

0 comments on commit 0ea04b0

Please sign in to comment.