Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
add svgr to storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
sballesteros committed Oct 11, 2019
1 parent 0b4a821 commit 512b2b9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
const path = require('path');

module.exports = async ({ config, mode }) => {
// See https://medium.com/@derek_19900/config-storybook-4-to-use-svgr-webpack-plugin-22cb1152f004
const fileLoaderRule = config.module.rules.find(rule =>
rule.test.test('.svg')
);
fileLoaderRule.exclude = [path.resolve(__dirname, '../src')];

config.module.rules.unshift(
// SVG
{
test: /\.svg$/,
use: ['@svgr/webpack']
}
);

config.module.rules.push({
test: /\.css$/,
sideEffects: true,
Expand Down
10 changes: 9 additions & 1 deletion src/components/home.stories.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import React from 'react';
import Home from './home';
import { BrowserRouter as Router } from 'react-router-dom';
import { UserProvider } from '../contexts/user-context';

export default { title: 'home' };

export function empty() {
return <Home />;
return (
<Router>
<UserProvider>
<Home />
</UserProvider>
</Router>
);
}
22 changes: 22 additions & 0 deletions src/utils/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,25 @@ export function getReviewAnswers(answerMap = {}) {
export function checkIfAllAnswered(answerMap = {}) {
return QUESTIONS.every(({ identifier }) => answerMap[identifier]);
}

export function checkIfHasReviewed(user = {}, actions = []) {
return arrayify(user.hasRole).some(role => {
return arrayify(actions).some(action => {
return (
action['@type'] === 'RapidPREreviewAction' &&
getId(action.agent) === getId(role)
);
});
});
}

export function checkIfHasRequested(user = {}, actions = []) {
return arrayify(user.hasRole).some(role => {
return arrayify(actions).some(action => {
return (
action['@type'] === 'RequestForRapidPREreviewAction' &&
getId(action.agent) === getId(role)
);
});
});
}

0 comments on commit 512b2b9

Please sign in to comment.