Skip to content

Commit e44a577

Browse files
cdmh219cdhenley219flacoman91
authored
Upgrade to Design System v3.x (#551)
* - Migrated from Less to Sass - Added postcss builder for icons - Upgraded to latest version of design system - Moved from Less to Sass variables - Move from @import to @use * Fixed issues with imported scss files * Removed old dependencies and theme overrides * Completed initial fixes for build errors * Completed initial fixes for build errors2 * stylelint less remove * Fixed config with linting * Fixed all linting errors * Various updates * Updated col classes to use mixins in new design system * incorporated design system updates into App.scss * updated tbd components with BEM notation and new design system classes Padding update in SearchPanel * Added licensed-font() mixin to add in fonts * Fixed media query syntax to work with Sass * fixed media queries pt 2 * fixed width of filter panel by adding a new class * Changed date range label * swapped out division to math.div() Sass function * final cleanup * production built files * took out IE 11 fixes for TileChartMap styles * update dist * Addressed PR feedback * Addressed PR feedback #2 * PR feedback updates #3 * Removed `from` syntax * Fixed background colors for modals --------- Co-authored-by: cdhenley219 <[email protected]> Co-authored-by: Richard Dinh <[email protected]>
1 parent 17edcdd commit e44a577

File tree

109 files changed

+658
-542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+658
-542
lines changed

.eslintrc.js .eslintrc.cjs

File renamed without changes.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This application allows consumers to search complaints submitted to the CFPB by
55

66
#### Technology Stack
77

8-
This application is written in JavaScript and [Less](http://lesscss.org) within
8+
This application is written in JavaScript and [Sass](https://sass-lang.com/) within
99
the [React](https://facebook.github.io/react/) + [Redux](http://redux.js.org/)
1010
framework. It uses [Webpack](http://webpack.github.io/docs/) at runtime to
1111
manage module loading.

craco.config.js

-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const CracoEsbuildPlugin = require('craco-esbuild');
2-
const CracoLessPlugin = require('craco-less');
32
const path = require('path');
43
const {
54
addAfterLoader,
@@ -82,24 +81,5 @@ module.exports = {
8281
skipEsbuildJest: true, // Optional. Set to true if you want to use babel for jest tests,
8382
},
8483
},
85-
{
86-
plugin: CracoLessPlugin,
87-
options: {
88-
lessLoaderOptions: {
89-
lessOptions: {
90-
modifyVars: {
91-
hack: `true;@import (reference) "${require.resolve(
92-
'./src/css/base.less',
93-
)}";`,
94-
},
95-
javascriptEnabled: true,
96-
math: 'always',
97-
paths: [
98-
path.resolve(__dirname, 'node_modules/@cfpb/cfpb-core/src'),
99-
],
100-
},
101-
},
102-
},
103-
},
10484
],
10585
};

dist/ccdb5.css

+2-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ccdb5.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ccdb5.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ccdb5.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+10-23
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"analyze": "craco build; source-map-explorer '../static/js/*.js'",
2424
"build": "NODE_ENV=production ./scripts/build.sh",
2525
"eject": "react-scripts eject",
26-
"lint": "yarn prettier \"src/**/*.{js,jsx,ts,tsx,json,md}\" --write && yarn eslint ./src --fix && yarn stylelint \"src/**/*.{css,less}\" --fix && yarn lint:cypress",
26+
"lint": "yarn prettier \"src/**/*.{js,jsx,ts,tsx,json,md}\" --write && yarn eslint ./src --fix && yarn stylelint \"src/**/*.{css,scss}\" --fix && yarn lint:cypress",
2727
"lint:cypress": "yarn eslint ./cypress --fix",
2828
"prepare": "husky",
2929
"release": "yarn run build && release-it --npm.skipChecks",
@@ -38,20 +38,10 @@
3838
"@babel/preset-react": "^7.24.7",
3939
"@babel/runtime": "^7.24.7",
4040
"@cfpb/browserslist-config": "0.0.2",
41-
"@cfpb/cfpb-atomic-component": "1.2.0",
42-
"@cfpb/cfpb-buttons": "1.3.0",
43-
"@cfpb/cfpb-core": "1.2.0",
44-
"@cfpb/cfpb-design-system": "^1.3.2",
45-
"@cfpb/cfpb-expandables": "^1.2.0",
46-
"@cfpb/cfpb-forms": "1.3.0",
47-
"@cfpb/cfpb-grid": "1.2.0",
48-
"@cfpb/cfpb-icons": "^1.2.0",
49-
"@cfpb/cfpb-layout": "1.3.0",
50-
"@cfpb/cfpb-notifications": "1.3.0",
51-
"@cfpb/cfpb-pagination": "1.3.0",
52-
"@cfpb/cfpb-tables": "1.2.0",
53-
"@cfpb/cfpb-typography": "1.3.2",
41+
"@cfpb/cfpb-design-system": "^3.2.2",
5442
"@craco/craco": "^7.1.0",
43+
"@csstools/postcss-sass": "^5.1.1",
44+
"@csstools/sass-import-resolve": "^1.0.0",
5545
"@reduxjs/toolkit": "^2.2.7",
5646
"@testing-library/cypress": "^10.0.2",
5747
"@testing-library/dom": "^10.4.0",
@@ -62,7 +52,6 @@
6252
"britecharts": "git+https://github.com/cfpb/britecharts.git#v2.4.2",
6353
"coveralls": "^3.0.9",
6454
"craco-esbuild": "^0.6.1",
65-
"craco-less": "^3.0.1",
6655
"cypress": "^13.11.0",
6756
"d3": "^7.9.0",
6857
"dayjs": "^1.11.10",
@@ -79,17 +68,14 @@
7968
"intro.js": "^7.2.0",
8069
"intro.js-react": "1.0.0",
8170
"jest-fetch-mock": "^3.0.3",
82-
"less": "^4.2.0",
83-
"less-loader": "^12.2.0",
84-
"less-plugin-clean-css": "^1.5.1",
8571
"lint-staged": "^15.2.7",
8672
"lodash": "^4.17.21",
8773
"mini-css-extract-plugin": "^2.9.0",
8874
"mockdate": "^3.0.5",
8975
"postcss": "^8.4.38",
90-
"postcss-less": "^6.0.0",
9176
"postcss-preset-env": "^9.5.13",
9277
"postcss-safe-parser": "^7.0.0",
78+
"postcss-scss": "^4.0.9",
9379
"prettier": "^3.3.1",
9480
"prop-types": "^15.5.10",
9581
"query-string": "^9.0.0",
@@ -103,13 +89,14 @@
10389
"react-scripts": "^5.0.1",
10490
"react-test-renderer": "^18.2.0",
10591
"release-it": "^17.3.0",
92+
"sass": "^1.79.4",
10693
"string-replace-loader": "^3.1.0",
10794
"stylelint": "^16.5.0",
10895
"stylelint-config-standard": "^36.0.0",
109-
"stylelint-less": "^3.0.1"
96+
"stylelint-config-standard-scss": "^13.1.0"
11097
},
11198
"lint-staged": {
112-
"src/**/*.{css,less}": [
99+
"src/**/*.{css,scss}": [
113100
"stylelint --fix"
114101
],
115102
"{cypress,src}/**/*.{js,jsx,ts,tsx,json,md}": [
@@ -144,10 +131,10 @@
144131
"text-summary"
145132
],
146133
"moduleNameMapper": {
147-
"\\.(css|less)$": "identity-obj-proxy"
134+
"\\.(css|scss)$": "identity-obj-proxy"
148135
},
149136
"transformIgnorePatterns": [
150-
"^.+\\.module\\.(css|less)$"
137+
"^.+\\.module\\.(css|scss)$"
151138
]
152139
},
153140
"publishConfig": {

postcss.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const { pluginProcessIcons } = require('./postcss/postcss-process-icons');
2+
module.exports = {
3+
plugins: [require('autoprefixer'), pluginProcessIcons],
4+
};

postcss/postcss-process-icons.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// modified from
2+
// https://github.com/cfpb/design-system/blob/main/esbuild/plugins/postcss-process-icons.js
3+
4+
const { readFileSync } = require('fs');
5+
const path = require('path');
6+
7+
const currentDir = path.dirname(__filename);
8+
9+
const pluginProcessIcons = () => {
10+
const stripQuotes = (str) => str.replace(/['"]+/g, '');
11+
12+
return {
13+
postcssPlugin: 'process-icons',
14+
Declaration: {
15+
'--cfpb-background-icon-svg': async (decl) => {
16+
const props = decl.value.split(' ');
17+
const iconName = stripQuotes(props[0]);
18+
const iconColor = props.length > 1 ? stripQuotes(props[1]) : '';
19+
20+
const pathToSVG =
21+
currentDir +
22+
'/../node_modules/@cfpb/cfpb-design-system/src/components/cfpb-icons/icons/' +
23+
iconName +
24+
'.svg';
25+
const rawSVG = await readFileSync(pathToSVG, 'utf8', (err, data) => {
26+
// eslint-disable-next-line no-console
27+
if (err) console.log(err);
28+
29+
return data;
30+
});
31+
32+
let cleanSVG = rawSVG;
33+
if (iconColor !== '') {
34+
cleanSVG = rawSVG.replace(
35+
/class="cf-icon-svg .+" /,
36+
`fill="${iconColor}" `,
37+
);
38+
}
39+
40+
decl.prop = 'background-image';
41+
decl.value = `url('data:image/svg+xml;charset=UTF-8,${cleanSVG}')`;
42+
},
43+
},
44+
};
45+
};
46+
pluginProcessIcons.postcss = true;
47+
48+
module.exports = { pluginProcessIcons };

src/App.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './css/App.less';
1+
import './css/App.scss';
22
import { Route, BrowserRouter as Router, Routes } from 'react-router-dom';
33
import { ComplaintDetail } from './components/ComplaintDetail/ComplaintDetail';
44
import { SearchComponents } from './components/Search/SearchComponents';

src/components/ActionBar/ActionBar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './ActionBar.less';
1+
import './ActionBar.scss';
22
import { useDispatch, useSelector } from 'react-redux';
33
import getIcon from '../iconMap';
44
import { sendAnalyticsEvent } from '../../utils';

src/components/ActionBar/ActionBar.less src/components/ActionBar/ActionBar.scss

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
1+
@use '@cfpb/cfpb-design-system/src/abstracts' as *;
2+
@use '@cfpb/cfpb-design-system/src/utilities' as *;
3+
@import '../../css/base';
4+
15
.action-bar {
26
border: 1px solid var(--gray-40);
37
border-left: 0; // Don't double the border with the filters
48
background-color: var(--green-20);
5-
padding: @gutter-normal @grid_gutter-width;
9+
padding: $gutter-normal $grid-gutter-width;
610

711
h2 {
812
margin: 0;
913

10-
@media @phone {
11-
padding: @gutter-normal;
14+
@media screen and (max-width: $layout-breakpoint-phone-max) {
15+
padding: $gutter-normal;
1216
}
1317
}
1418

1519
.export-results {
16-
padding-top: @gutter-minimum;
20+
padding-top: $gutter-minimum;
1721
margin: 0;
18-
margin-bottom: @gutter-minimum;
22+
margin-bottom: $gutter-minimum;
1923
.a-btn {
20-
margin-right: @gutter-normal;
21-
font-size: @size-v;
24+
margin-right: $gutter-normal;
25+
font-size: $size-v;
2226

2327
svg {
24-
margin-right: @gutter-minimum;
28+
margin-right: $gutter-minimum;
2529
}
2630
}
2731
}
@@ -44,15 +48,15 @@
4448
}
4549
}
4650

47-
@media @phone {
51+
@media screen and (max-width: $layout-breakpoint-phone-max) {
4852
padding-left: 0;
4953
border: 1px solid var(--gray-40);
5054
.export-results {
5155
margin-left: 15px;
5256
}
5357
}
5458

55-
@media @superwide {
59+
@media screen and (min-width: $layout-breakpoint-superwide-min){
5660
padding-left: 40px;
5761
}
5862
}

src/components/Charts/ChartWrapper/ChartWrapper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './ChartWrapper.less';
1+
import './ChartWrapper.scss';
22
import { ErrorBlock } from '../../Warnings/Error';
33
import PropTypes from 'prop-types';
44

src/components/Charts/LineChart/LineChart.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './LineChart.less';
1+
import './LineChart.scss';
22
import * as d3 from 'd3';
33
import line from 'britecharts/dist/umd/line.min';
44
import tooltip from 'britecharts/dist/umd/tooltip.min';

src/components/Charts/LineChart/LineChart.less src/components/Charts/LineChart/LineChart.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
display: none;
4545
}
4646
}
47-
//line on hover for the tooltip.
47+
48+
// line on hover for the tooltip.
4849
.vertical-marker {
4950
stroke: var(--gray-20);
5051
stroke-width: 2px;

src/components/Charts/RowChart/RowChart.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './RowChart.less';
1+
import './RowChart.scss';
22
import * as d3 from 'd3';
33
import { max } from 'd3-array';
44
import { miniTooltip, row } from 'britecharts';

src/components/Charts/RowChart/RowChart.less src/components/Charts/RowChart/RowChart.scss

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
@use 'node_modules/@cfpb/cfpb-design-system/src/abstracts' as *;
2+
@use 'node_modules/@cfpb/cfpb-design-system/src/base' as *;
3+
@use 'node_modules/@cfpb/cfpb-design-system/dist/index.css' as *;
4+
@import '../../../css/base';
5+
16
.row-chart-section {
2-
margin-top: @grid_gutter-width;
3-
margin-left: @grid_gutter-width;
7+
margin-top: $grid-gutter-width;
8+
margin-left: $grid-gutter-width;
49

510
p {
611
max-width: none;
712
}
813
}
914

10-
@media @phone {
15+
@media screen and (max-width: $layout-breakpoint-phone-max) {
1116
.row-chart-section {
1217
margin-left: 0;
1318
}

src/components/Charts/StackedAreaChart/StackedAreaChart.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './StackedAreaChart.less';
1+
import './StackedAreaChart.scss';
22
import * as d3 from 'd3';
33
import { stackedArea } from 'britecharts';
44
import { useEffect, useMemo } from 'react';

src/components/Common/TooltipWrapper/TooltipWrapper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './TooltipWrapper.less';
1+
import './TooltipWrapper.scss';
22
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
33
import PropTypes from 'prop-types';
44
import Tooltip from 'react-bootstrap/Tooltip';

src/components/Common/TooltipWrapper/TooltipWrapper.less src/components/Common/TooltipWrapper/TooltipWrapper.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
--bs-popover-border-color: var(--bs-border-color-translucent);
120120
--bs-popover-border-radius: 0.5rem;
121121
--bs-popover-inner-border-radius: calc(0.5rem - 1px);
122-
--bs-popover-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 15%);
122+
--bs-popover-box-shadow: 0 0.5rem 1rem rgb(0 0 0 / 15%);
123123
--bs-popover-header-padding-x: 1rem;
124124
--bs-popover-header-padding-y: 0.5rem;
125125
--bs-popover-header-font-size: 1rem;

src/components/ComplaintDetail/ComplaintDetail.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import './ComplaintDetail.less';
1+
import './ComplaintDetail.scss';
22
import { useEffect, useMemo } from 'react';
33
import { useDispatch, useSelector } from 'react-redux';
44
import {

0 commit comments

Comments
 (0)