Giter VIP home page Giter VIP logo

fem-notification-page's Introduction

Frontend Mentor - Notifications page solution

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.

Table of contents

Overview

The challenge

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

Screenshot

light mode

notification page light mode

dark mode

notification page dark mode

Links

Built with

What I learned

  • 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 from styled components
const GlobalStyle = createGlobalStyle<{ theme: themeProps }>`

Continued development

  • Make the ThemeToggle component more accesible as well as the whole app

Useful resources

  • 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 type string can't be used to index helped me out when I got a similar error. I discovered that Typescript understands a dynamic key may have any value and so Typescript throws an error. To solve this, you must cast the dynamic key as a type of the object type or in this case, the iconprops interface.

Author

Acknowledgments

fem-notification-page's People

Contributors

jonathan401 avatar

Stargazers

Roman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.