This is a solution to the Notifications page challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- Distinguish between "unread" and "read" notifications
- Select "Mark all as read" to toggle the visual state of the unread notifications and set the number of unread messages to zero
- View the optimal layout for the interface depending on their device's screen size
- See hover and focus states for all interactive elements on the page
- Solution URL: Github Repo
- Live Site URL: Deployed using vercel
- Semantic JSX markup
- Mobile-first workflow
- React - JS library
- Styled Components - For styles
-
More about how Typescript works
-
How to conditionally style components based on typed props in styled components
export const StyledComponent = styled.div<{ bg: bgType }>`
background-color: ${({ bg }) => bg};
`;
-
How to add theming using the styled component's
Theme Provider Component
-
How to define types for contexts with default values
const ThemeContext = createContext<ThemeContextType | null>(null);
- You have to cast a type for a dynamic key
const Icon = iconMap[notificationType as keyof iconProps].icon;
- define type for
createGlobalStyle
function fromstyled components
const GlobalStyle = createGlobalStyle<{ theme: themeProps }>`
- Make the
ThemeToggle
component more accesible as well as the whole app
-
Theming - This is a really wonderful article that helped me understand how to add theme to react apps using styled components. I really liked this pattern and will use it going forward.
-
React Context and Typescript - This is an amazing article which helped me finally understand how to use React Context and Typescript in a React Typescript app. I'd recommend it to anyone still learning this concept.
-
Creating accessible toggle - This article helped me create an accessible toggle component
-
Stackoverflow - A stackoverflow solution to the error Element implicitly has an
any
type because expression of typestring
can't be used to index helped me out when I got a similar error. I discovered that Typescript understands adynamic key
may have any value and so Typescript throws an error. To solve this, you must cast thedynamic key
as a type of theobject type
or in this case, theiconprops
interface.
- Github - Jonathan Gomina
- Frontend Mentor - @jonathan401
- Twitter - @GominaKehinde4
-
Adriano Escarabote's dark theme feature on his Skilled E Landing page Frontend Mentor solution
-
Karol's Frontend Mentor Notification page solution.