Coder Social home page Coder Social logo

andrewjbateman / angular-tailwind-sncf Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 5.77 MB

:clipboard: Angular app using Tailwind styles to display SNCF data from the Navitia API

JavaScript 3.77% TypeScript 60.66% HTML 31.16% SCSS 2.90% CSS 1.51%
angular pwa sncf navitia-api navitia scss tailwind rest-api observables rxjs7

angular-tailwind-sncf's Introduction

⚑ Angular Tailwind SNCF

  • Angular app using TailwindCSS components to display mobility data from the Navitia API with i18n language selection
  • Note: to open web links in a new window use: ctrl+click on link

GitHub repo size GitHub pull requests GitHub Repo stars GitHub last commit

πŸ“„ Table of contents

πŸ“š General info

  • User searches for a station name and Leaflet maps shows location of stations with that name around Paris
  • Transloco internationalization (i18n) library for Angular used to enable user to switch between English, Spanish and French. VERSION 4 ONLY - not v5 or v6 or nothing works :-(
  • About and Contact pages give more information on app using Tailwind CSS cards
  • To build for production Tailwind’s purge option is used to tree-shake unused styles and optimize final build size.
  • The Github API does not require an API key for a basic user profile search.
  • The Navitia API does require an API key. It is a Hypermedia As The Engine Of Application State (HATEOAS) API that returns JSON formatted results. Using places search
  • Angular standalone components used to reduce amount of code and complexity.

πŸ“· Screenshots

Angular page

πŸ“Ά Technologies

πŸ’Ύ Setup

  • Run npm i to install dependencies.
  • Get yourself an API key by registering with Navitia.io
  • Add API key to the environments.ts file
  • Run ng serve for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
  • Run npm run build for a production build with css purging.
  • Run http-server to view build on an apple/android phone or simulator (pick 2nd http address supplied)
  • The build artifacts will be stored in the dist/angular-tailwind-sncf directory.

πŸ”§ Testing

  • Run ng test to run Jasmine unit tests via Karma. Currrently 8/12 tests pass

πŸ’» Code Examples

  • function from station-list.component.ts to return a list of stations from a user input string
  // search for stations matching user search input
  // observable displayed in template using Angular async pipe
  onSubmitStationSearch(stationSearch: NgForm): void {
    if (this.stations) {
      this.stations = [];
    }
    let searchName = this.sanitizeInput(stationSearch.form.value.stationName);
    if (searchName) {
      this.loading = true; // Set loading state to true
      this.subscription = this.stationService
        .apiStationSearch(searchName, this.stationCount)
        .subscribe((data: SncfResponse[]) => (this.stations = data[0].places));
      this.loading = false; // Set loading state to false after data is fetched
    }
  }

πŸ†’ Features

  • standalone components used to reduce boiler-plate code
  • Tailwind build for production CSS purge results in a very small styles bundle (about tba kB)

πŸ“‹ Status & To-Do List

  • Status: Working.
  • To-Do: Add error-reporting service, language dropdown menu active CSS. Clear map for new search. Make it an SSR. Deploy.
  • Optional: Convert to graphQL

πŸ‘ Inspiration

πŸ“ License

  • This project is licensed under the terms of the MIT license.

βœ‰οΈ Contact

angular-tailwind-sncf's People

Contributors

andrewjbateman avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

aichouramine

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.