Code Monkey home page Code Monkey logo

falcon's Introduction

Netlify Status GitHub issues


Falcon

The main code-base is written in react with a mix of Typescript and Javascript.

Running the frontend locally

First install the required dependencies using:

$ yarn

Then start the live server for development using:

$ yarn start

Deployment

Currently the master branch is set to auto-deploy on netlify and can be viewed at: lttkgp.com.

Netlify also automatically builds deploy previews of any pull requests which can be accessed in the specific PRs themselves.

Overview of the Project

Views

Currently there are three default views (routes):

  1. Home (/)
  2. Feed (/feed)
  3. Genre (/genre)

These are present with their respective names in src/views.

1. Home

The homepage is meant to be a go-to place for a regular user of the application. It consists of a few List components that allow a user to quickly view what is hot and happening in the LTTKGP community.

2. Feed

Feed is the main feed of the community. It replicates the feed of the facebook page and can be used to browse all the videos posted there.

3. Genre (:hammerand_wrench: _planned)

Genre page is meant to allow users to discover/navigate the posts according to genres.

Video

This is another route which is not exactly a generic view. This component is rendered whenever a user navigates to a video.

The route changes to /video?=<id> where <id>is the of the currently playing song.

This component consists of the video player, which uses the YouTube component from react-youtube library to display the youtube video and functions/logic to change the video and display the queue.

Components

The major components and there use-cases are discussed below. For a detailed overview, it is recommended to look directly at the code related to each of the components.

These are present in the src/components directory with relevant filenames.

CSwitch (Custom Switch)

This is the main Switch for the react-router library. The Video page gets the id of the current song through code in this switch.

Sidebar

This component is responsible for the sidebar displayed in desktop and tablet views. This also transforms into the bottom navigation for mobile view.

The logic to change theme and sidebar size is abstracted away in utility functions discussed later.

Header

A simple header that is used for the heading of a page. It includes the title and also the theme switcher for dark-mode that is displayed in the mobile view.

๐Ÿ› ๏ธ The search input to be added later can be added here, although there will be better approaches as the route would most probably be changed to /search after entering the query.

List

This renders the lists on the homepage. The component needs just the title and a API URL that returns a list of posts.

All of the logic pertaining to the scrolling are contained in this component.

Card

This is the card that is displayed within the list. It contains the display logic and instructions on playing the song when it is selected.

FeedCard

This component is similar to the Card component but is intended to be used in the feed. It displays a little more data including the captions and post date which is relevant to the feed.

Note that the Card and FeedCard are quite related in their functionality however, they are not connected in code. Thus, changing a fundamental thing in one will not be reflected in the other. The same is true for the styles of these components.

Global State

The only thing store currently in the global state is the queue so that it can be accessed by the video component when the view changes as well as the route.

Do remember to set the queue whenever you switch to a video page to play a video.

Utils

These are utilitarian functions that are used throughout the application.

These are present in /src/utils with appropriate names.

Some of these are discussed here:

  1. joinArtist : Combines artist names into a string that can be displayed in the artist section
  2. filterUniqueVideos : Removes duplicate videos from a list of posts.
  3. filterGenres : Removes duplicate genres from the array of genres.
  4. shuffle : Performs a knuth-shuffle on a given array.
  5. changeTheme : Changes the theme of the app, it coverts light -> dark and vice-versa, and stores it in the localStorage.
  6. setThemeOnUserPref : This checks if the user prefers dark mode by, first checking the localStorage and then in the system settings. It then applies the dark mode.
  7. changeExpand : Changes the class of the sidebar in desktop mode to switch between the expanded and contracted variant.
  8. mobileCheck : This function returns true if the app is currently being visited via a mobile.

Styles

The styling of the project is done mainly in SCSS. Some dynamic elements such as grid sizes are handled using styled-components.

However, it is recommended to keep the styles in SCSS files and only put the styles that depend exclusively upon javascript variables to be written in styled-components.

The different styles pertaining to the different components and views are named accordingly.

All the files are imported in the main App.scss file. If you create a new file for the styles, don't forget to import it in the App.scss file. This will allow you to use the color variables and Responsive mixins in your new file.

There are several helpful variables and mixins used throughout the SCSS:

Color variables

These variables are used throughout for the basis and the sass functions such as lighten etc. are used wherever necessary to slightly alter these.

The variables necessary for dark mode are contained in the dark.scss file.

Responsive Mixins

These mixins can be used to apply styles for the three responsive sizes.

These are defined in the responsive.scss file.

These can be used in the SCSS files as shown below:

Mobile

@include sm {
  // your styles here
}

Tablet

@include md {
  // your styles here
}

Desktop

@include lg {
  // your styles here
}

Dark mode

The styles that are specific to dark mode are present here. Since the dark mode is applied globally, the only necessary thing to change is the icon and the colors of the page.

It is recommended to keep all logic except that of the colors in the original styles for the component and use the dark.scss file to override the colors involved.

falcon's People

Contributors

dependabot[bot] avatar ghostwriternr avatar j-tesla avatar priyanshux avatar rakaar avatar sahil-shubham avatar shouryaveer avatar xypnox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

falcon's Issues

Add basic documentation

Currently there is nothing in terms of documentation for this project.
Even the Readme is empty.

Add basic documentation for a start with description/usage of custom elements and components.

Add filters in feed

The feed serves as the replica of the feed of Facebook group. Currently it doesn't have any filters to sort and browse the posts. The following filters need to be added:

  • Like Count
  • Date interval
  • Genres

These filters will also be replicated in the search page when it is added.

Back button working unexpectedly

Here is a short video depicting unexpected behaviour of Back button. Here is a long video depicting the same issue. In both the videos one can see that the back button works occasionally.

I am facing the same problem in another project. If you know how to fix it, please let me know in the comments. It seems, Reacts router doesn't re-render the component when the query string changes.(ref)

Add a global state for the queue of the current player

The state should be either a redux store or a context store.

It will save

  • the current queue and
  • the current playing song

and should expose functions to

  • change the currently playing song
  • load next set of songs
  • Shuffle the queue and move the currently playing song to the top
  • optional
    • filter queue
    • load history
      • queue history can be stored in localstorage

The state will be necessary in various operations:

  • Load more videos when the end of the queue is reached #50
  • Populate queue when only ID is passed in /video route #51
  • Load next videos in the queue #57
  • Updating the video and queue and automatically handling change of URL. #72
    let changeURLid = (id: string) => {
    if (window !== undefined) {
    if (window.history.pushState) {
    var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + "?=" + id;
    window.history.pushState({ path: newurl }, "", newurl);
    }
    }
    };

Add About page

Add an about page to the site to list:

  • About LTTKGP
  • Features
  • FAQs
  • GitHub Org and Slack Workspace links
  • Change-log/Link to a changelog elsewhere

The About page can be added as an info icon above the theme switcher.

The design of the about page should be attractive as it will be the primary source for users to know about LTTKGP.

Add additional info in video description

There are few parameters which are still not displayed in the description, the following need to be added:

  • Artist Image
  • Song Art
  • Post data
  • Link to post on FB

Shows "Loading" when its not loading

The backend is giving some errors currently.

Error 1016
Origin DNS error

When the backend fails, the frontend should show some error or info like "check back later." The loading message is misleading.

image

empty `List` in Home

image
Now, popular endpoint is giving empty list. Hiding empty lists would be a better experiecne to the users rather than displaying empty space with shuffle button which throws error in console on click.

Create a list for random songs

The /random endpoint returns random songs from the DB. We can create a 'Surprise Me' type of list where the user can listen to random songs that were posted before.

Organize additional information and settings

As the content and the features of the app have increased, the space in the UI has started cramming up. For example consider the #62 About page PR. This will add another button besides the theme switcher to the interface.

As we grow further we may need more pages and configurations. Sticking them to the sidebar will only clutter the interface further. Therefore we need a solution to organize existing configs and links, and have flexibility to add any configs in the future; Without sacrificing the minimal feel of the interface.

One of the solutions is a modal shown on hover located at the bottom of the sidebar:

Frame 7(1)

Frame 6(3)

This modal is designed to take minimal space. We can extend it both horizontally and vertically to add future elements.

The button for the modal is located at the same place as the previous theme switcher thus making it familiar to the older users. It has been moved inside the modal because people don't switch themes regularly, they choose one theme and stick to it throughout.

On mobile this will be a full width and height modal with a close icon to close it. The button to launch it will be at the same place as the theme switcher, beside the page titles.

This modal will also include the post stale status provided by the backend.

I didn't prefer a centered modal. I wanted it to take only as much visual space as it required. Putting it in the center would cover the video lists and the hover to show interaction would not be feasible with this approach.

We will need to test the accessibility of such a modal as this will have to be implemented by hand.

I am also open to other ideas to fit the configs and links in one place/other places.

Scroll to the video if lower in queue

Currently the queue opens at the top even when a song lower in the queue is selected in the list.

Fix the error by adding the scroll if the current index is not the first video.

Store the result of API calls in redux store

Currently every time a view is visited after the site has loaded calls the API again to fetch the posts. It would be better to store the result of the API calls in the redux store and use those values instead.

If a user wants to fetch the new posts he/she just needs to refresh the page and it will clear the redux store and refresh the posts, thus there is no need to add an auto-refresh.

Artist name and some genres are hidden

Artist name and some genres are hidden when the song name crosses into the next line or the viewport dimensions are not large enough.

fsvdbgbdvhrtdv

Screenshot & reported by @thescriptninja

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.