Giter VIP home page Giter VIP logo

question-editor's Introduction

Question Editor for a Radio Button Matrix

Built with create-react-app, Styled-Components, CSS Grid and React Transition Group.

Features:

  • Ability to select images from the hard drive for every row and column
  • Ability to set labels for every row and column
  • Ability to add new rows and columns
  • Ability to remove rows and columns
  • A statistics panel

Scripts

In the project directory, you can run:

yarn start or npm run start

Runs the app in the development mode on http://localhost:3000.
The page will reload if you make edits, lint errors shows in the console.

yarn test or npm run test

Launches the test runner in the interactive watch mode.

yarn build or npm run build

Builds the app for production to the build folder.
The build is minified and the filenames include the hashes.

How it works

Structure

Application's state is managed in App.js component.

Table with radio button matrix is wrapped in styled /Table component, which has CSS Grid properties to render each children in a cell by column flow, this means first renders delete cells, after that image cells and so on...
Advantage of rendering by grid column flow is that it's automatically adjusts width of that particular column if one of the cell's width has been changed (i.e. changing row/columns labels).

Management

Radio buttons

Checked attributes are managed in each row's state, under checked key, by false/true value. When user selects radio button, method handleRadioChange() is being called, which maps through checked values, setting up all to false, except the chosen. This let's user to chose only one option per row.

Row/column labels

Similarly to radio buttons, each of input tag's value is controlled by state, which changes when user enters text. Also has size attribute, which changes dinamicaly, to adjust text length.

File uploads

File uploads are managed by input tags with type attribute of file.

File reading is managed by web API FileReader object, which lets web applications asynchronously read the contents of files stored on the user's computer.

After user uploads file, new instance of FileReader and FileReader.onloadend handler event is created, which tracks when file ends to upload.

Calling FileReader.readAsDataURL() method, reads the content, once finished, the result attribute FileReader.result contains URL representing the file's data.

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.