Skip to content

Commit

Permalink
React 18 and NextJS 14
Browse files Browse the repository at this point in the history
  • Loading branch information
dooman87 committed Mar 18, 2024
1 parent 8214e3e commit b70ad4f
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 1,449 deletions.
7 changes: 4 additions & 3 deletions components/Agenda/Agenda.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { SafeLink } from 'components/global/safeLink'
import { SessionGroup, useSessionGroups } from 'components/utils/useSessionGroups'
import { StyledCenteredParagraph, StyledSponsorLogo } from 'components/Agenda/Agenda.styled'
import { SessionDetails } from 'components/Agenda/SessionDetails'
import { StyledCloseButton, StyledDialogContent, StyledDialogOverlay } from 'components/Agenda/SessionDetails.styled'
import { StyledCloseButton, StyledDialogContent } from 'components/Agenda/SessionDetails.styled'
import ReactModal from 'react-modal'
export type onSelectCallback = (session: Session, sponsor: Sponsor, livestream: string) => void

interface AgendaProps {
Expand Down Expand Up @@ -96,7 +97,7 @@ export const Agenda = ({ sessions, ...props }: AgendaProps) => {
<React.Fragment>
{props.render(sessions, nextSessionGroup, onSelectHandler)}

<StyledDialogOverlay isOpen={sessionState.showModal} onDismiss={onDismissHandler}>
<ReactModal isOpen={sessionState.showModal} onDismiss={onDismissHandler}>
<StyledDialogContent>
<StyledCloseButton type="button" className="close-button" onClick={onDismissHandler} aria-label="Close">
<span aria-hidden>×</span>
Expand Down Expand Up @@ -137,7 +138,7 @@ export const Agenda = ({ sessions, ...props }: AgendaProps) => {
</Fragment>
)}
</StyledDialogContent>
</StyledDialogOverlay>
</ReactModal>
</React.Fragment>
)
}
Expand Down
5 changes: 2 additions & 3 deletions components/Agenda/SessionDetails.styled.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { DialogContent, DialogOverlay } from '@reach/dialog'
import { breakpoint, breakpointMax } from 'components/utils/styles/breakpoints'
import { calcRem } from 'components/utils/styles/calcRem'
import styled from '@emotion/styled'
import { zIndex } from 'components/utils/styles/zindex'

export const StyledDialogOverlay = styled(DialogOverlay)({
export const StyledDialogOverlay = styled('div')({
position: 'fixed',
top: 0,
right: 0,
Expand All @@ -16,7 +15,7 @@ export const StyledDialogOverlay = styled(DialogOverlay)({
})
StyledDialogOverlay.displayName = 'StyledDialogOverlay'

export const StyledDialogContent = styled(DialogContent)({
export const StyledDialogContent = styled('div')({
position: 'relative',
width: '90vw',
padding: calcRem(15),
Expand Down
4 changes: 4 additions & 0 deletions components/Agenda/SessionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export const SessionDetails = ({
hideLevelAndFormat = false,
showBio,
}: SessionDetailsProps) => {
if (!session) {
return <div>Uh Oh</div>
}

return (
<Fragment>
<StyledSessionTitle>{session.Title}</StyledSessionTitle>
Expand Down
3 changes: 1 addition & 2 deletions components/Voting/landing.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import styled from '@emotion/styled'
import { Button } from 'components/global/Button/Button'
import { Text } from 'components/global/text'
import { calcRem } from 'components/utils/styles/calcRem'
import { DialogContent } from '@reach/dialog'
import { breakpointMax } from '../utils/styles/breakpoints'

export const StyledLandingContainer = styled('div')(() => ({
Expand Down Expand Up @@ -54,7 +53,7 @@ export const StyledFormRow = styled('div')({
marginBottom: calcRem(30),
})

export const StyledDialogContent = styled(DialogContent)({
export const StyledDialogContent = styled('div')({
[breakpointMax('sm')]: {
width: '100%',
},
Expand Down
49 changes: 0 additions & 49 deletions components/global/Alert/Alert.styled.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1 @@
import styled from '@emotion/styled'
import Alert from '@reach/alert'
import { calcRem } from 'components/utils/styles/calcRem'
import { DDDTheme } from 'components/utils/styles/theme'

export type Kind = 'info' | 'success' | 'error' | 'warning'

interface StyledAlertProps {
kind: Kind
}

function stylesFromKind(kind: StyledAlertProps['kind'], theme: DDDTheme) {
switch (kind) {
case 'error':
return {
backgroundColor: theme.colors.alerts.error.background,
borderColor: theme.colors.alerts.error.border,
color: theme.colors.alerts.error.color,
}
case 'success':
return {
backgroundColor: theme.colors.alerts.success.background,
borderColor: theme.colors.alerts.success.border,
color: theme.colors.alerts.success.color,
}
case 'warning':
return {
backgroundColor: theme.colors.alerts.warning.background,
borderColor: theme.colors.alerts.warning.border,
color: theme.colors.alerts.warning.color,
}
default:
return {
backgroundColor: theme.colors.alerts.info.background,
borderColor: theme.colors.alerts.info.border,
color: theme.colors.alerts.info.color,
}
}
}

// @ts-ignore
export const StyledAlert = styled(Alert, {
shouldForwardProp: (prop) => prop !== 'kind',
})<StyledAlertProps>(({ kind, theme }) => ({
padding: calcRem(15),
margin: calcRem(0, 0, 20),
border: '1px solid transparent',
borderRadius: calcRem(4),
...stylesFromKind(kind, theme),
}))
11 changes: 9 additions & 2 deletions components/global/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import React, { ReactNode } from 'react'
import { Kind, StyledAlert } from './Alert.styled'
import { Kind } from './Alert.styled'

interface AlertProps {
kind: Kind
children: ReactNode
type?: 'assertive' | 'polite'
}

export const Alert = (props: AlertProps) => <StyledAlert {...props} />
export const Alert = (props: AlertProps) => {
return (
<div>
Alert HERE
{props.children}
</div>
)
}
11 changes: 4 additions & 7 deletions components/global/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import * as ReactGA from 'react-ga'

declare global {
interface Window {
appInsights: any
}
}

export const init = (googleAnalyticsId: string): void => {
ReactGA.initialize(googleAnalyticsId)
export const init = (_googleAnalyticsId: string): void => {
// TODO
}

export const getSessionId = (): string | null => {
Expand All @@ -17,8 +15,7 @@ export const getSessionId = (): string | null => {
}

export const logPageView = (): void => {
ReactGA.set({ page: window.location.pathname })
ReactGA.pageview(window.location.pathname)
// TODO
if (window.appInsights) {
window.appInsights.trackPageView()
}
Expand All @@ -44,7 +41,7 @@ export const logEvent = (category: string, action: string, data: any, measuremen
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const logException = (description: string, exception: Error, data: any): void => {
if (description) {
ReactGA.exception({ description, exception: exception.toString() })
// TODO
if (window.appInsights && window.appInsights.trackException) {
window.appInsights.trackException(exception, 'unhandled', {
description,
Expand Down
4 changes: 2 additions & 2 deletions components/venueMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const MapEvents = () => {
}

const Map = ({ roomLocationData }) => {
const [map, setMap] = useState(null)
const [map, _setMap] = useState(null)
const userLocButton = useRef(null)

useEffect(() => {
Expand Down Expand Up @@ -167,7 +167,7 @@ const Map = ({ roomLocationData }) => {
style={{ height: 700, width: '100%' }}
minZoom={19}
maxZoom={22}
whenCreated={setMap}
//TODO: whenReady={setMap}
>
<TileLayer
attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
Expand Down
Loading

0 comments on commit b70ad4f

Please sign in to comment.