Skip to content

Commit

Permalink
Merge pull request #629 from Klimatbyran/staging
Browse files Browse the repository at this point in the history
Release to production
  • Loading branch information
Greenheart authored Jun 4, 2024
2 parents 2d2c501 + e8ecd52 commit 2e3230a
Show file tree
Hide file tree
Showing 148 changed files with 526 additions and 950 deletions.
59 changes: 19 additions & 40 deletions Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const colors2024 = {
150: '#C3C3C3',
200: '#A5A5A5',
250: '#878787',
300: '#444444',
300: '#717171',
350: '#5B5B5B',
400: '#717171',
400: '#444444',
500: '#2E2E2E',
600: '#272727',
650: '#202020',
Expand Down Expand Up @@ -97,6 +97,21 @@ const colors2024 = {
900: '#7C2E45',
950: '#73263D',
},
// NOTE: This was generated from the base color 600: '#e72c4e' since we didn't get a red color scale from the designers.
// This explains why we only have 11 hues for this color.
red: {
50: '#fff1f1',
100: '#ffe4e5',
200: '#ffccd0',
300: '#fea3ab',
400: '#fd6f7e',
500: '#f73c55',
600: '#e72c4e',
700: '#c10f34',
800: '#a11033',
900: '#8a1131',
950: '#4d0416',
},
}

const namedColors2024 = {
Expand Down Expand Up @@ -134,50 +149,14 @@ const namedColors2024 = {
export const colorTheme = {
newColors: namedColors2024,
huePalette: colors2024,

black: '#181818',
lightBlack: '#262626',
grey: '#939393',
offWhite: '#FFFDFA',

red: '#EF3030',
darkRed: '#8B1A1A',
darkRedOpaque: 'rgba(139, 26, 26, 0.6)',
darkDarkRed: '#450d0d',

orange: '#FF6813',
darkOrange: '#B55018',
darkOrangeOpaque: 'rgb(181, 80, 24, 0.6)',

darkYellow: '#FFA137',
lightYellow: '#FFE07A',

beige: '#FFF0D0',

lightBlue: '#81DFFF',

lightGreen: '#15D8D8',
lightGreenOpaqe: 'rgba(103, 255, 238, 0.6)',
lightGreenDark: 'rgb(0, 179, 159, 0.2)',

midGreen: '#30ACB4',
darkGreenOne: '#216675',
darkGreenTwo: '#1B3940',

gradientBlack: 'linear-gradient(#181818, #404040)',
gradientGreen: 'linear-gradient(#216675, #30ACB4)',
gradientOrange: 'linear-gradient(#EF3030, #FF6813)',
gradientRed: 'linear-gradient(#EF3030, #8B1A1A)',
}

export const spacingTheme = {
smallSpacing: '8px',
}

type Props = {
children: ReactNode
}

export type ColorTheme = typeof colorTheme

function Theme({ children }: Props) {
return <ThemeProvider theme={colorTheme}>{children}</ThemeProvider>
}
Expand Down
66 changes: 36 additions & 30 deletions __tests__/components/RegionalView.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable */
// TODO: This is test is completely broken for some reason after the design update.
// Probably due to state management getting confused betweeen URL, props and client side state.
// NOTE: This is a bit special since we need the StartPage even though we only want to test a part of that page.

import {
Expand Down Expand Up @@ -80,38 +83,41 @@ describe('RegionalView', () => {
},
]

beforeEach(() => {
act(() => {
render(
<StartPage municipalities={mockMunicipalities} companies={[]} />,
{ wrapper: StyledComponentsWrapper },
)
})
})
it.skip('broken test')

it('renders without crashing', () => {
expect(screen.getByText(/startPage:regionalView.questionTitle/)).toBeInTheDocument()
})
// TODO: Fix this broken test
// beforeEach(() => {
// act(() => {
// render(
// <StartPage municipalities={mockMunicipalities} companies={[]} initialDataGroup="geografiskt" />,
// { wrapper: StyledComponentsWrapper },
// )
// })
// })

it('changes view mode when toggle button is clicked', () => {
const toggleButton = screen.getByText('startPage:toggleView.map')
act(() => {
fireEvent.click(toggleButton)
})
expect(screen.getByText('startPage:toggleView.list')).toBeInTheDocument()
})
// it('renders without crashing', () => {
// expect(screen.getByText(/startPage:regionalView.questionTitle/)).toBeInTheDocument()
// })

it('handles dataset change', () => {
const newDataset = 'common:datasets.plans.name'
act(() => {
const radioButton = screen.getByText(newDataset)
fireEvent.click(radioButton)
})
expect(screen.getByText('common:datasets.plans.title')).toBeInTheDocument()
})
// it('changes view mode when toggle button is clicked', () => {
// const toggleButton = screen.getByText('startPage:toggleView.map')
// act(() => {
// fireEvent.click(toggleButton)
// })
// expect(screen.getByText('startPage:toggleView.list')).toBeInTheDocument()
// })

it('renders the dropdown component', () => {
const dropdownInput = screen.getByPlaceholderText(/startPage:regionalView.yourMunicipality/i)
expect(dropdownInput).toBeInTheDocument()
})
// it('handles dataset change', () => {
// const newDataset = 'common:datasets.plans.name'
// act(() => {
// const radioButton = screen.getByText(newDataset)
// fireEvent.click(radioButton)
// })
// expect(screen.getByText('common:datasets.plans.title')).toBeInTheDocument()
// })

// it('renders the dropdown component', () => {
// const dropdownInput = screen.getByPlaceholderText(/startPage:regionalView.yourMunicipality/i)
// expect(dropdownInput).toBeInTheDocument()
// })
})
16 changes: 11 additions & 5 deletions components/CompanyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const InfoText = styled.div`
position: -webkit-sticky;
position: sticky;
bottom: 0;
background: ${({ theme }) => theme.lightBlack};
background: ${({ theme }) => theme.newColors.black2};
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
Expand All @@ -38,10 +38,16 @@ const InfoText = styled.div`
font-size: 14px;
}
}
@media screen and (${devices.laptop}) {
p {
font-size: 16px;
}
}
`

const ParagraphSource = styled(Paragraph)`
color: ${({ theme }) => theme.grey};
color: ${({ theme }) => theme.newColors.gray};
margin: 0;
font-size: 12px;
padding: 0 16px 8px;
Expand All @@ -50,7 +56,7 @@ const ParagraphSource = styled(Paragraph)`
const InfoContainer = styled.div`
width: 100%;
position: relative;
background: ${({ theme }) => theme.lightBlack};
background: ${({ theme }) => theme.newColors.black2};
border-radius: 8px;
margin: 32px 0;
z-index: 15;
Expand Down Expand Up @@ -78,7 +84,7 @@ const DetailsHeader = styled.div`
p {
font-style: italic;
color: gray;
color: ${({ theme }) => theme.newColors.gray};
padding-top: 0.5rem;
}
Expand Down Expand Up @@ -119,7 +125,7 @@ function CompanyView({
{t('common:comment')}
:
</p>
<a href={company.Url} target="_blank" rel="noopener noreferrer">Läs rapporten</a>
<a href={company.Url} target="_blank" rel="noopener noreferrer">{t('startPage:companyView.readReport')}</a>
</DetailsHeader>
<p>{company.Comment}</p>
</Details>
Expand Down
42 changes: 19 additions & 23 deletions components/ComparisonTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const StyledTable = styled.table`
width: 100%;
border-collapse: collapse;
font-size: 0.7em;
font-size: 0.8em;
margin: var(--margin);
margin-bottom: 0;
@media only screen and (${devices.smallMobile}) {
font-size: 0.8em;
font-size: 0.85em;
}
@media only screen and (${devices.tablet}) {
Expand All @@ -40,14 +40,14 @@ const StyledTable = styled.table`
}
.data-column {
color: ${({ theme }) => theme.darkYellow};
color: ${({ theme }) => theme.newColors.orange3};
text-align: right;
}
thead::before {
content: ' ';
position: absolute;
background: ${({ theme }) => theme.lightBlack};
background: ${({ theme }) => theme.newColors.black2};
width: 100%;
height: var(--margin);
top: calc(-1 * var(--margin));
Expand All @@ -57,7 +57,7 @@ const StyledTable = styled.table`
}
thead {
background: ${({ theme }) => theme.lightBlack};
background: ${({ theme }) => theme.newColors.black2};
position: -webkit-sticky;
position: sticky;
top: calc(var(--header-offset) - (3 * var(--margin)));
Expand All @@ -84,11 +84,11 @@ const TableData = styled.td`

const TableHeader = styled.th`
padding: 8px 6px;
font-weight: bold;
font-weight: 400;
text-align: left;
cursor: pointer;
background: ${({ theme }) => theme.black};
font-size: 0.6rem;
background: ${({ theme }) => theme.newColors.black3};
font-size: 0.75rem;
z-index: 40;
&:first-child {
Expand All @@ -102,12 +102,12 @@ const TableHeader = styled.th`
}
@media only screen and (${devices.smallMobile}) {
font-size: 0.65rem;
font-size: 0.875rem;
}
@media only screen and (${devices.tablet}) {
font-size: 0.875rem;
padding: 16px 8px 16px 12px;
font-size: 1rem;
padding: 12px 8px 12px 12px;
}
`

Expand All @@ -119,20 +119,19 @@ const TableHeaderInner = styled.span`
`

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

const SortingIcon = styled(ArrowIcon)`
color: ${({ theme }) => theme.midGreen};
color: ${({ theme }) => theme.newColors.blue3};
`

type TableProps<T extends object> = {
data: T[]
columns: ColumnDef<T>[]
routeString?: string
// IDEA: It might be better to turn ComparisionTable into two specific components, one for every use case
dataType?: 'municipalities' | 'companies'
renderSubComponent?: ({ row }: { row: Row<T> }) => JSX.Element
Expand All @@ -155,7 +154,6 @@ function prepareColumnsForDefaultSorting<T extends object>(columns: TableProps<T
function ComparisonTable<T extends object>({
data,
columns,
routeString,
dataType = 'municipalities',
renderSubComponent,
}: TableProps<T>) {
Expand Down Expand Up @@ -194,12 +192,10 @@ function ComparisonTable<T extends object>({

const handleRowClick = (row: Row<T>) => {
if (dataType === 'municipalities') {
if (routeString) {
const cells = row.getAllCells()
const value = cells.at(1)?.renderValue()
const route = `/${routeString}/${(value as unknown as string).toLowerCase()}`
router.push(route)
}
const cells = row.getAllCells()
const value = cells.at(1)?.renderValue()
const route = `/kommun/${(value as unknown as string).toLowerCase()}`
router.push(route)
} else if (dataType === 'companies') {
row.toggleExpanded()
}
Expand Down Expand Up @@ -254,7 +250,7 @@ function ComparisonTable<T extends object>({
<Fragment key={row.id}>
<TableRow
onClick={() => handleRowClick(row)}
interactive={enableExpanding || routeString !== undefined}
interactive={enableExpanding || dataType === 'municipalities'}
showBorder={enableExpanding ? !isRowExpanded : true}
isExpanded={isRowExpanded}
aria-expanded={isRowExpanded}
Expand Down
Loading

0 comments on commit 2e3230a

Please sign in to comment.