Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
98 changes: 30 additions & 68 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,38 @@
// This file has been automatically migrated to valid ESM format by Storybook.

const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
import path, { dirname } from 'path';
import htmlPurge from 'vite-plugin-html-purgecss';
import {fileURLToPath} from 'url';
import react, { reactCompilerPreset } from '@vitejs/plugin-react';
import { mergeConfig } from 'vite';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export default {
// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
framework: '@storybook/react-webpack5',
stories: ['./stories/*.mdx', './stories/*.stories.@(js|jsx|mjs|ts|tsx)'],
staticDirs: ['../public', '../static','../assets','../assets/fonts', '../assets/img']
};
module.exports = {
stories: ['./**/stories/*.@(stories.@(js))','./**/stories/*.@(mdx)'],
framework: '@storybook/react-vite',
stories: ['./**/stories/*.@(stories.@(jsx))','./**/stories/*.@(mdx)'],
core: {
builder: '@storybook/builder-vite',
},
build: {
outDir: path.resolve(__dirname, "./docs"),
emptyOutDir: true
},
staticDirs: ['../assets','../assets/fonts', '../assets/img', '../styles'],
addons: [
"@storybook/addon-links",
"@storybook/addon-webpack5-compiler-babel",
"@chromatic-com/storybook",
"@storybook/addon-docs",
"@storybook/addon-styling-webpack",
"@storybook/addon-links",
"@chromatic-com/storybook",
"@storybook/addon-docs",
'@storybook/addon-vitest',
'@storybook/addon-a11y',
],
webpack: (config, options) => {
options.cache.set = () => Promise.resolve();
return config;
},
webpackFinal: async (config) => {
config.plugins.push(new MiniCssExtractPlugin());
config.module.rules.push({
test: /\.js$|jsx$/,
exclude: /node_modules\.*/,
loader: "babel-loader"
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: "css-loader"
}
]
},
{
include: /\.(eot|ttf|woff|woff2|png|svg|ico|gif|jpg|pdf|webp)$/,
loader: 'file-loader',
type: 'javascript/auto',
options: {
name: '[path][name].[ext]'
}
},
{
test: /\.scss$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
{ loader: "css-loader", options: { url: false, sourceMap: true } },
{
loader: "sass-loader",
options: {
sourceMap: true,
sassOptions: {
includePaths: ["./src/_scss", "./node_modules"]
}
}
}
]
async viteFinal(config) {
return mergeConfig(config, {
});
return config;
},
framework: {
name: '@storybook/react-webpack5',
options: {}
},
docs: {},
typescript: {
reactDocgen: 'react-docgen-typescript'
}
docs: {},
typescript: {
reactDocgen: 'react-docgen-typescript'
}
};
4 changes: 3 additions & 1 deletion .storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,7 @@
/* $file-formats: eot woff2 woff ttf */
}
</style>

<script>
window.global = window;
</script>
<title>Data Transparency UI</title>
11 changes: 1 addition & 10 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { DocsPage, DocsContainer } from '@storybook/addon-docs/blocks';
import { INITIAL_VIEWPORTS } from 'storybook/viewport';
import { library } from "@fortawesome/fontawesome-svg-core";

Expand Down Expand Up @@ -91,10 +90,6 @@ import dataTransparencyUiTheme from './theme';
// where global scss styles get applied
import '../styles/storybook.scss';
export const parameters = {
docs: {
container: DocsContainer,
page: DocsPage,
},
options: {
name: 'Data Transparency UI',
storySort: (a, b) => {
Expand All @@ -109,7 +104,7 @@ export const parameters = {
tags: ['autodocs']
},
viewport: {
viewports: INITIAL_VIEWPORTS,
options: INITIAL_VIEWPORTS,
},
a11y: {
element: 'body',
Expand All @@ -124,8 +119,4 @@ export const parameters = {
},
},
};

export const decorators = [
(storyFn) => <div style={{ width: "100%" }}>{storyFn()}</div>,
];
export const tags = ['autodocs'];
2 changes: 1 addition & 1 deletion .storybook/stories/card.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Meta, Canvas, Controls} from '@storybook/addon-docs/blocks';
import * as CardStories from "./card.stories";
import * as CardStories from "./card.stories.jsx";
import CardBody from "../../components/cards/CardBody";
import CardButton from "../../components/cards/CardButton";
import CardHero from "../../components/cards/CardHero";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { TabsWrapper, TabsTooltip, InformationBoxesWrapper } from '../misc';
import InformationBoxes from '../../components/InformationBoxes';

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import Table from '../../components/table/Table';
import TooltipWrapper from '../../components/infoTooltip/TooltipWrapper';
import TooltipComponent from '../../components/infoTooltip/TooltipComponent';
import { TableWrapper, BasicTableWrapper, CustomColumnExample } from '../misc';
import { TableWrapper, BasicTableWrapper } from '../misc';

export default {
title: 'Tables/Table',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { TabsWrapper, TabsTooltip, TabsWrapperShowTooltip } from '../misc';
import { TabsWrapper } from '../misc';
import Tabs from '../../components/tabs/Tabs';

export default {
Expand Down
7 changes: 7 additions & 0 deletions .storybook/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
import { setProjectAnnotations } from '@storybook/react-vite';
import * as projectAnnotations from './preview';

// This is an important step to apply the right configuration when testing your stories.
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
15 changes: 4 additions & 11 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
const presets = [
"@babel/preset-react",
[
"@babel/preset-env",
{
targets: {
ie: "10",
node: "10"
},
useBuiltIns: "entry",
corejs: { version: 3, proposals: true }
}
],
"@babel/preset-react"
]
];

const plugins = [
"@babel/plugin-syntax-jsx",
[
"module-resolver",
{
Expand All @@ -29,7 +22,7 @@ const plugins = [
}]
];

module.exports = {
export default {
presets,
plugins
};
2 changes: 1 addition & 1 deletion components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import React from 'react';
import PropTypes from "prop-types";

require('../styles/components/_buttons.scss');
import '../styles/components/_buttons.scss';

const propTypes = {
buttonSize: PropTypes.oneOf(['large', 'medium', 'small', 'lg', 'md', 'sm']).isRequired,
Expand Down
2 changes: 1 addition & 1 deletion components/Carousel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, { cloneElement, useEffect, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import { uniqueId } from 'lodash-es';

require('../styles/components/_carousel.scss');
import '../styles/components/_carousel.scss';

const propTypes = {
items: PropTypes.arrayOf(PropTypes.element)
Expand Down
2 changes: 1 addition & 1 deletion components/DownloadIconButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { faSpinner, faFileDownload } from '@fortawesome/free-solid-svg-icons';

import TooltipWrapper from './infoTooltip/TooltipWrapper';

require('../styles/components/_downloadIconButton.scss');
import '../styles/components/_downloadIconButton.scss';

const propTypes = {
onClick: PropTypes.func.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion components/FiscalYearPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { faCalendarAlt } from '@fortawesome/free-regular-svg-icons';
import Picker from './Picker';
import { allFiscalYears } from '../helpers/fiscalYearHelper';

require('../styles/components/_fiscalYearPicker.scss');
import '../styles/components/_fiscalYearPicker.scss';

const defaultSort = (a, b) => {
if (Number.isInteger(a)) return b - a;
Expand Down
2 changes: 1 addition & 1 deletion components/InPageNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { mediumScreen, largeScreen, xLargeScreen } from '../dataMapping/mobileBreakpoints';
import { checkIsOverflow, getElementData, reset } from '../helpers/inPageNavHelper';

require('../styles/components/_inPageNav.scss');
import '../styles/components/_inPageNav.scss';

const propTypes = {
sections: PropTypes.array,
Expand Down
4 changes: 2 additions & 2 deletions components/InformationBoxes.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { throttle } from 'lodash-es';
import { formattedValue, numberToText } from '../helpers/informationBoxesHelper';
import { formattedValue, numberToText } from '../helpers/informationBoxesHelper.js';

require('../styles/components/_informationBoxes.scss');
import '../styles/components/_informationBoxes.scss';

const propTypes = {
boxes: PropTypes.arrayOf(PropTypes.shape({
Expand Down
2 changes: 1 addition & 1 deletion components/NewPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { uniqueId } from 'lodash-es';

require('../styles/components/_newPicker.scss');
import '../styles/components/_newPicker.scss';

const propTypes = {
size: PropTypes.oneOf(['sm', 'md', 'lg', 'small', 'medium', 'large']),
Expand Down
2 changes: 1 addition & 1 deletion components/PageHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';

import InPageNav from './InPageNav';

require('../styles/components/_pageHeader.scss');
import '../styles/components/_pageHeader.scss';

const PageHeader = ({
title,
Expand Down
3 changes: 1 addition & 2 deletions components/Picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import React, { useRef, useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { uniqueId } from 'lodash-es';

require('../styles/components/_picker.scss');
import '../styles/components/_picker.scss';

const fontAwesomeIconId = "usa-dt-picker__button-icon--svg";

Expand Down
2 changes: 1 addition & 1 deletion components/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { resetOrSubmitSearch, shouldResetSearchTerm } from '../helpers/searchBarHelper';

require('../styles/components/_searchBar.scss');
import '../styles/components/_searchBar.scss';

const propTypes = {
onSearch: PropTypes.func,
Expand Down
2 changes: 1 addition & 1 deletion components/SearchResultsTableWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import React from 'react';
import PropTypes from "prop-types";

require('../styles/components/_searchResultsTableWrapper.scss');
import '../styles/components/_searchResultsTableWrapper.scss';

const propTypes = {
tableComponent: PropTypes.func.isRequired
Expand Down
2 changes: 1 addition & 1 deletion components/SectionHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import TooltipWrapper from './infoTooltip/TooltipWrapper';

require('../styles/components/_sectionHeader.scss');
import '../styles/components/_sectionHeader.scss';

function SectionHeader({
icon, title, overLine, description, titleTooltip, descTooltip
Expand Down
2 changes: 1 addition & 1 deletion components/SectionWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SectionHeader from './SectionHeader';
import ComingSoon from './messages/ComingSoon';
import { createOnKeyDownHandler } from '../helpers/keyboardEventsHelper';

require('../styles/components/_sectionWrapper.scss');
import '../styles/components/_sectionWrapper.scss';

const defaultControlledProps = {
isControlled: false,
Expand Down
2 changes: 1 addition & 1 deletion components/ShareIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { faCheckCircle } from "@fortawesome/free-solid-svg-icons";
import Picker from "./Picker";
import { socialShareOptions } from '../helpers/socialShare';

require('../styles/components/_shareIcon.scss');
import '../styles/components/_shareIcon.scss';

const propTypes = {
url: PropTypes.string.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion components/cards/CardContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import React from 'react';
import PropTypes from "prop-types";

require('../../styles/components/cards/_cards.scss');
import '../../styles/components/cards/_cards.scss';

const propTypes = {
variant: PropTypes.string, // elevated, outline, or none
Expand Down
3 changes: 1 addition & 2 deletions components/flexGrid/FlexGridCol.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { createClassString } from '../../helpers/flexGridHelper';

require('../../styles/components/_flexGrid.scss');
import '../../styles/components/_flexGrid.scss';

export default function GridCol({
children,
Expand Down
2 changes: 1 addition & 1 deletion components/flexGrid/FlexGridContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { createClassString } from '../../helpers/flexGridHelper';

require('../../styles/components/_flexGrid.scss');
import '../../styles/components/_flexGrid.scss';

export default function GridContainer({ children, className, ...props }) {
return (
Expand Down
2 changes: 1 addition & 1 deletion components/flexGrid/FlexGridRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import cx from 'classnames';
import { createClassString } from '../../helpers/flexGridHelper';

require('../../styles/components/_flexGrid.scss');
import '../../styles/components/_flexGrid.scss';

const GridRow = ({
children,
Expand Down
2 changes: 1 addition & 1 deletion components/infoTooltip/TooltipWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { throttle, uniqueId } from "lodash-es";
import cx from 'classnames';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

require('../../styles/components/infoTooltip/_tooltipWrapper.scss');
import '../../styles/components/infoTooltip/_tooltipWrapper.scss';

const propTypes = {
className: PropTypes.string,
Expand Down
Loading