Skip to content

Commit 06e5e58

Browse files
authored
Update fonts and colors to match the new design (Klimatbyran#593)
* Add new font DM Sans Variable and replace Borna * Remove unneeded Borna font files * Use consistent font weights * Update default font weights. Also tweak table font size. * Remove unused fonts Source Serif and Roboto * WIP: Replace Anonymous Pro * Format numbers with locale-aware formatter * Remove Anonymous Pro and use new font DM Sans Variable instead * Improve styles * Make footer links look a bit nicer with the new font * No need to override default font for graph * Add new colors * Remove unused spacingTheme and move colors config * Fix broken translation * Use locale-aware number formatting instead of Number.toFixed() * Replace lightBlack with black2 * Update PageWrappers to use transparent background as default instead of passing explicit black (which was used almost everywhere) * Tweak padding and remove gray table headers due to bad contrast and bad accessibility * Update header to use new color scheme * Update social icons to match new colors * Remove @types/styled-components since styled-components provides its own types as of v6.0.0 * Declare types for our styled-components Theme to provide auto-completion * Use new colors for PillSwitch * Tweak colors for landing page * Improve table colors * Use currentColor in SVG icons * Remove unused export * Tweak colors * Tweak colors * Use consistent colors * Ensure MapLabels always stay on top of the map. Fix Klimatbyran#528 * Improve map labels * Ensure placeholder styles are applied * Update map colors to make it easier to distinguish between different values * Replace remaining old colors with new alternatives * Remove unused colors and icon * Remove unused margins * Initial color improvement for graphs * UX: Don't show the budget tooltips during step 1 of the municipality Graph to avoid confusing users * Remove remaining old colors from theme * Fix invalid order for gray colors * Fix button colors * Add transparency for blue color in the graph * Add red coolor scale and isuggestion for map colors * Suggestion: Change the boundaries for municipality emission colors, to make it better reflect the dataset * Improve contrast for PillSwitch * Memoize map data to improve rendering performance * Remove unused variable and simplify logic * Use red colors in graph * Whitespace fix * Fix/only show climateplan link for actual links (Klimatbyran#608) * Only show link to climate plan when it exists. This makes it more obvious when the plan is missing. * Use link instead of button * Highlight if climate plans are missing * Remove link underline * Improve UX and fix bugs for Municipality pages (Klimatbyran#609) * Improve Footer layout and allow adding partial footers * Add layout and footer to municipality pages * Navigate back to municipality datasets instead of company datasets to make it easier to compare * Bugfix: Render correct RegionalView based on URL state * Bugfix: use correct margin top for the list view * Merge branch 'feature/new-font-and-colors' into fix/add-footer-to-municipality-pages * Remove irrelevant comment * Increase font-size on larger screens for the ComparisionTable footer text * Change opacity * Make it possible to change the default dataView for RegionalView in one place. This fixes the same bug for the third time in the past few days. * Add missing translation * Remove dynamic to speed up loading for map * Remove transition to reduce negative impact of slow load, rendering and blaoted page data * Fix buggy default state for the dataView * Use initialDataGroup instead of normalizedDataGroup to avoid nasty routing bugs * Bug fix with invalid URL for redirect * Simplify type * Force useState to sync with the clicked URL * Improve map colors to make it more accessible for people who only see black and white * Make the emission reduction colors more representative for the actual state of the emission reductions. Also use even numeric spans, to make the scale show the spread of values instead of skewing towards one axis. (Klimatbyran#611) For examle, the emissions map for municipalities was completely misrepresenting the data, and minimizing how serious the gap is between what is needed and what is happening. * Tweak map colors to make better use of the current map colors * Fix red color for MunicipalityEmissionNumbers * Add transparency to the graph background colors
1 parent 95d67c2 commit 06e5e58

File tree

146 files changed

+489
-919
lines changed

Some content is hidden

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

146 files changed

+489
-919
lines changed

Theme.tsx

+19-40
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const colors2024 = {
88
150: '#C3C3C3',
99
200: '#A5A5A5',
1010
250: '#878787',
11-
300: '#444444',
11+
300: '#717171',
1212
350: '#5B5B5B',
13-
400: '#717171',
13+
400: '#444444',
1414
500: '#2E2E2E',
1515
600: '#272727',
1616
650: '#202020',
@@ -97,6 +97,21 @@ const colors2024 = {
9797
900: '#7C2E45',
9898
950: '#73263D',
9999
},
100+
// NOTE: This was generated from the base color 600: '#e72c4e' since we didn't get a red color scale from the designers.
101+
// This explains why we only have 11 hues for this color.
102+
red: {
103+
50: '#fff1f1',
104+
100: '#ffe4e5',
105+
200: '#ffccd0',
106+
300: '#fea3ab',
107+
400: '#fd6f7e',
108+
500: '#f73c55',
109+
600: '#e72c4e',
110+
700: '#c10f34',
111+
800: '#a11033',
112+
900: '#8a1131',
113+
950: '#4d0416',
114+
},
100115
}
101116

102117
const namedColors2024 = {
@@ -134,50 +149,14 @@ const namedColors2024 = {
134149
export const colorTheme = {
135150
newColors: namedColors2024,
136151
huePalette: colors2024,
137-
138-
black: '#181818',
139-
lightBlack: '#262626',
140-
grey: '#939393',
141-
offWhite: '#FFFDFA',
142-
143-
red: '#EF3030',
144-
darkRed: '#8B1A1A',
145-
darkRedOpaque: 'rgba(139, 26, 26, 0.6)',
146-
darkDarkRed: '#450d0d',
147-
148-
orange: '#FF6813',
149-
darkOrange: '#B55018',
150-
darkOrangeOpaque: 'rgb(181, 80, 24, 0.6)',
151-
152-
darkYellow: '#FFA137',
153-
lightYellow: '#FFE07A',
154-
155-
beige: '#FFF0D0',
156-
157-
lightBlue: '#81DFFF',
158-
159-
lightGreen: '#15D8D8',
160-
lightGreenOpaqe: 'rgba(103, 255, 238, 0.6)',
161-
lightGreenDark: 'rgb(0, 179, 159, 0.2)',
162-
163-
midGreen: '#30ACB4',
164-
darkGreenOne: '#216675',
165-
darkGreenTwo: '#1B3940',
166-
167-
gradientBlack: 'linear-gradient(#181818, #404040)',
168-
gradientGreen: 'linear-gradient(#216675, #30ACB4)',
169-
gradientOrange: 'linear-gradient(#EF3030, #FF6813)',
170-
gradientRed: 'linear-gradient(#EF3030, #8B1A1A)',
171-
}
172-
173-
export const spacingTheme = {
174-
smallSpacing: '8px',
175152
}
176153

177154
type Props = {
178155
children: ReactNode
179156
}
180157

158+
export type ColorTheme = typeof colorTheme
159+
181160
function Theme({ children }: Props) {
182161
return <ThemeProvider theme={colorTheme}>{children}</ThemeProvider>
183162
}

components/CompanyView.tsx

+11-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const InfoText = styled.div`
1313
position: -webkit-sticky;
1414
position: sticky;
1515
bottom: 0;
16-
background: ${({ theme }) => theme.lightBlack};
16+
background: ${({ theme }) => theme.newColors.black2};
1717
border-bottom-left-radius: 8px;
1818
border-bottom-right-radius: 8px;
1919
@@ -38,10 +38,16 @@ const InfoText = styled.div`
3838
font-size: 14px;
3939
}
4040
}
41+
42+
@media screen and (${devices.laptop}) {
43+
p {
44+
font-size: 16px;
45+
}
46+
}
4147
`
4248

4349
const ParagraphSource = styled(Paragraph)`
44-
color: ${({ theme }) => theme.grey};
50+
color: ${({ theme }) => theme.newColors.gray};
4551
margin: 0;
4652
font-size: 12px;
4753
padding: 0 16px 8px;
@@ -50,7 +56,7 @@ const ParagraphSource = styled(Paragraph)`
5056
const InfoContainer = styled.div`
5157
width: 100%;
5258
position: relative;
53-
background: ${({ theme }) => theme.lightBlack};
59+
background: ${({ theme }) => theme.newColors.black2};
5460
border-radius: 8px;
5561
margin: 32px 0;
5662
z-index: 15;
@@ -78,7 +84,7 @@ const DetailsHeader = styled.div`
7884
7985
p {
8086
font-style: italic;
81-
color: gray;
87+
color: ${({ theme }) => theme.newColors.gray};
8288
padding-top: 0.5rem;
8389
}
8490
@@ -119,7 +125,7 @@ function CompanyView({
119125
{t('common:comment')}
120126
:
121127
</p>
122-
<a href={company.Url} target="_blank" rel="noopener noreferrer">Läs rapporten</a>
128+
<a href={company.Url} target="_blank" rel="noopener noreferrer">{t('startPage:companyView.readReport')}</a>
123129
</DetailsHeader>
124130
<p>{company.Comment}</p>
125131
</Details>

components/ComparisonTable.tsx

+19-23
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ const StyledTable = styled.table`
2222
2323
width: 100%;
2424
border-collapse: collapse;
25-
font-size: 0.7em;
25+
font-size: 0.8em;
2626
margin: var(--margin);
2727
margin-bottom: 0;
2828
2929
@media only screen and (${devices.smallMobile}) {
30-
font-size: 0.8em;
30+
font-size: 0.85em;
3131
}
3232
3333
@media only screen and (${devices.tablet}) {
@@ -40,14 +40,14 @@ const StyledTable = styled.table`
4040
}
4141
4242
.data-column {
43-
color: ${({ theme }) => theme.darkYellow};
43+
color: ${({ theme }) => theme.newColors.orange3};
4444
text-align: right;
4545
}
4646
4747
thead::before {
4848
content: ' ';
4949
position: absolute;
50-
background: ${({ theme }) => theme.lightBlack};
50+
background: ${({ theme }) => theme.newColors.black2};
5151
width: 100%;
5252
height: var(--margin);
5353
top: calc(-1 * var(--margin));
@@ -57,7 +57,7 @@ const StyledTable = styled.table`
5757
}
5858
5959
thead {
60-
background: ${({ theme }) => theme.lightBlack};
60+
background: ${({ theme }) => theme.newColors.black2};
6161
position: -webkit-sticky;
6262
position: sticky;
6363
top: calc(var(--header-offset) - (3 * var(--margin)));
@@ -84,11 +84,11 @@ const TableData = styled.td`
8484

8585
const TableHeader = styled.th`
8686
padding: 8px 6px;
87-
font-weight: bold;
87+
font-weight: 400;
8888
text-align: left;
8989
cursor: pointer;
90-
background: ${({ theme }) => theme.black};
91-
font-size: 0.6rem;
90+
background: ${({ theme }) => theme.newColors.black3};
91+
font-size: 0.75rem;
9292
z-index: 40;
9393
9494
&:first-child {
@@ -102,12 +102,12 @@ const TableHeader = styled.th`
102102
}
103103
104104
@media only screen and (${devices.smallMobile}) {
105-
font-size: 0.65rem;
105+
font-size: 0.875rem;
106106
}
107107
108108
@media only screen and (${devices.tablet}) {
109-
font-size: 0.875rem;
110-
padding: 16px 8px 16px 12px;
109+
font-size: 1rem;
110+
padding: 12px 8px 12px 12px;
111111
}
112112
`
113113

@@ -119,20 +119,19 @@ const TableHeaderInner = styled.span`
119119
`
120120

121121
const TableRow = styled.tr<{ interactive?: boolean, showBorder?: boolean, isExpanded?: boolean }>`
122-
border-bottom: ${({ showBorder, theme }) => (showBorder ? `1px solid ${theme.midGreen}` : '')};
122+
border-bottom: ${({ showBorder, theme }) => (showBorder ? `1px solid ${theme.newColors.blue3}` : '')};
123123
cursor: ${({ interactive }) => (interactive ? 'pointer' : '')};
124-
background: ${({ isExpanded, theme }) => (isExpanded ? `${theme.black}88` : '')};
124+
background: ${({ isExpanded, theme }) => (isExpanded ? theme.newColors.black1 : '')};
125125
z-index: 10;
126126
`
127127

128128
const SortingIcon = styled(ArrowIcon)`
129-
color: ${({ theme }) => theme.midGreen};
129+
color: ${({ theme }) => theme.newColors.blue3};
130130
`
131131

132132
type TableProps<T extends object> = {
133133
data: T[]
134134
columns: ColumnDef<T>[]
135-
routeString?: string
136135
// IDEA: It might be better to turn ComparisionTable into two specific components, one for every use case
137136
dataType?: 'municipalities' | 'companies'
138137
renderSubComponent?: ({ row }: { row: Row<T> }) => JSX.Element
@@ -155,7 +154,6 @@ function prepareColumnsForDefaultSorting<T extends object>(columns: TableProps<T
155154
function ComparisonTable<T extends object>({
156155
data,
157156
columns,
158-
routeString,
159157
dataType = 'municipalities',
160158
renderSubComponent,
161159
}: TableProps<T>) {
@@ -194,12 +192,10 @@ function ComparisonTable<T extends object>({
194192

195193
const handleRowClick = (row: Row<T>) => {
196194
if (dataType === 'municipalities') {
197-
if (routeString) {
198-
const cells = row.getAllCells()
199-
const value = cells.at(1)?.renderValue()
200-
const route = `/${routeString}/${(value as unknown as string).toLowerCase()}`
201-
router.push(route)
202-
}
195+
const cells = row.getAllCells()
196+
const value = cells.at(1)?.renderValue()
197+
const route = `/kommun/${(value as unknown as string).toLowerCase()}`
198+
router.push(route)
203199
} else if (dataType === 'companies') {
204200
row.toggleExpanded()
205201
}
@@ -254,7 +250,7 @@ function ComparisonTable<T extends object>({
254250
<Fragment key={row.id}>
255251
<TableRow
256252
onClick={() => handleRowClick(row)}
257-
interactive={enableExpanding || routeString !== undefined}
253+
interactive={enableExpanding || dataType === 'municipalities'}
258254
showBorder={enableExpanding ? !isRowExpanded : true}
259255
isExpanded={isRowExpanded}
260256
aria-expanded={isRowExpanded}

components/DatasetButtonMenu.tsx

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import styled from 'styled-components'
1+
import styled, { css } from 'styled-components'
22
import { DataDescriptions, DatasetKey } from '../utils/types'
33
import { devices } from '../utils/devices'
44

55
const ButtonContainer = styled.div`
66
margin: 8px 0 32px 0;
77
gap: 8px;
88
display: flex;
9-
font-weight: bolder;
109
flex-wrap: wrap;
1110
justify-content: center;
1211
@@ -18,31 +17,26 @@ const ButtonContainer = styled.div`
1817

1918
const Button = styled.button<{active: boolean}>`
2019
padding: 8px 16px;
21-
font-family: 'Anonymous Pro';
2220
font-size: 16px;
21+
font-weight: 400;
2322
text-decoration: none;
24-
line-height: 19px;
25-
color: ${({ theme }) => theme.offWhite};
26-
background: ${({ theme }) => theme.lightBlack};
23+
color: ${({ theme }) => theme.newColors.white};
24+
background: ${({ theme }) => theme.newColors.black2};
2725
border: none;
2826
border-radius: 8px;
2927
white-space: nowrap;
3028
box-sizing: border-box;
3129
cursor: pointer;
3230
3331
&:hover {
34-
background: ${({ theme }) => theme.darkGreenTwo};
32+
color: ${({ theme }) => theme.newColors.black3};
33+
background: ${({ theme }) => theme.newColors.blue1};
3534
}
3635
37-
${({ theme, active }) => active && `
38-
color: ${theme.black};
39-
background: ${theme.midGreen};
40-
41-
&:hover {
42-
background-color: ${theme.lightGreen};
43-
}
36+
${({ theme, active }) => active && css`
37+
color: ${theme.newColors.black3};
38+
background: ${theme.newColors.blue2} !important;
4439
`}
45-
4640
`
4741

4842
type MenuProps = {

components/DropDown.tsx

+9-10
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,23 @@ const Flex = styled.div`
3333
const StyledInput = styled.input`
3434
width: 100%;
3535
height: 56px;
36-
background-color: transparent;
37-
border: 1px solid ${({ theme }) => theme.midGreen};
36+
background: ${({ theme }) => theme.newColors.white};
37+
border: 0;
3838
border-radius: 4px;
39-
color: ${({ theme }) => theme.offWhite};
39+
color: ${({ theme }) => theme.newColors.black3};
4040
font-size: 16px;
41-
font-weight: 300;
42-
font-family: Borna;
41+
font-family: 'DM Sans Variable', sans-serif;
4342
padding-left: 0.8rem;
4443
outline: none;
4544
width: 325px;
4645
47-
::placeholder {
48-
color: ${({ theme }) => theme.offWhite};
46+
&::placeholder {
47+
color: ${({ theme }) => theme.newColors.black2};
4948
}
5049
`
5150

5251
const Btn = styled.button`
53-
background-color: transparent;
52+
background: transparent;
5453
width: 20px;
5554
height: 20px;
5655
right: 16px;
@@ -59,7 +58,7 @@ const Btn = styled.button`
5958
`
6059

6160
const MunicipalitiesWrapper = styled.ul`
62-
background-color: ${({ theme }) => theme.lightBlack};
61+
background-color: ${({ theme }) => theme.newColors.black2};
6362
border-radius: 4px;
6463
max-height: 195px;
6564
overflow-y: scroll;
@@ -68,7 +67,7 @@ const MunicipalitiesWrapper = styled.ul`
6867
`
6968

7069
const Municipality = styled.li`
71-
color: ${({ theme }) => theme.offWhite};
70+
color: ${({ theme }) => theme.newColors.white};
7271
text-decoration: none;
7372
width: 310px;
7473
height: 56px;

0 commit comments

Comments
 (0)