Giter VIP home page Giter VIP logo

gwaphics's Introduction

Gwaphics

Gwaphics Live Demo

Gwaphics, a Canva clone, is a online graphical design tool for creating designs effortlessly. Aside from creating shapes, text, and image elements on a blank canvas using intuitive drag & drop features, Users also have a variety of inspiring public design templates to choose from.

Editor Screenshot

Technologies

Features

User Authentication

Greeted by a splash page, users may sign-in or sign-up as a new member (using BCrypt for password hashing), also with the choice of logging in as a demo user.

Designs

Designs are the main feature of the Gwaphics project. Aside from storing meta-data about the design itself, a design most importantly holds references to all the elements associated with it. While these kinds of one-to-many associations are usually handled with NoSQL databases with embedded sub-documents, Gwaphics utilizes rails' nested attributes and polymorphic associations to ensure a Relational database such as PostgreSQL could also achieve minimal backend API calls.

class Design < ApplicationRecord
  accepts_nested_attributes_for :elements, allow_destroy: true
end

According to our schema, a design has_many elements which either has_many shapes, text, images or stockphotos, the tricky part for polymorphic associations to accept nested attributes, is to override the accepts_nested_attributes_for build method to take in elementable_type and find a declared constant with the specified name.

class Element < ApplicationRecord
  accepts_nested_attributes_for :elementable

  def build_elementable(params)
    self.elementable = elementable_type.constantize.new(params)
  end
end

Thus, our designs_controller only takes in one single design payload to populate/modify all corresponding tables. With the frontend state handling the temporary attributes of creating/editing a design, Gwaphics minimizes the API calls for either create, update, and delete actions with one single API call on user save.

Drag and Drop demo

The visual representation of borders indicating the selection of elements which may overlap with one another, is handled by simultaneously rendering a "controlled component" which is on a higher z-index.

<Draggable position={{ x: x - 2, y: y - 2 }}>
  <div
    className={styles.selected}
    style={{
      width: selected.elementableAttributes.width * zoom,
      height: selected.elementableAttributes.height * zoom,
    }}
  />
</Draggable>

The above Draggable higher-order component is completely controlled by the local React state's position x and y, with minor offsets making space for the highlighting border to render. Which each time a user selects an element below, the onControlledDrag handler syncs the position of the element with the selection border.

elements.map((element, index) => {
  if (element._destroy) return null;
  return (
    <Draggable
      key={element.id ? element.id : index}
      onDrag={this.onControlledDrag}
      onStop={(e, data) => this.onControlledDragStop(e, index, data)}
      position={{ x: element.posX * zoom, y: element.posY * zoom }}
    >
      <div style={{ position: 'absolute', zIndex: element.zIndex }} onClick={() => setSelected(index)}>
        <Element element={element} zoom={zoom} />
      </div>
    </Draggable>
  );
})

Thumbnails

Thumbnails of designs

Thumbnails are generated to ensure the efficiency of loading multiple designs on a page. Gwaphics runs "Puppeteer" as an external ExpressJS API, a headless chromium browser that navigates to the sharable link of each design on user save, which then captures the page with the given width and height. The screenshot response is sent back as a base64 string, processed to be a JavaScript File type, and then uploaded to AWS S3 via Active Storage.

export const createThumbnail = ({ id, width, height }) => (
  fetch(`https://gwaphics-pup.herokuapp.com/screenshot?id=${id}&width=${width}&height=${height}`)
    .then((res) => res.blob())
    .then((blob) => {
      const file = new File([blob], 'File name', { type: 'image/png' });
      return file;
    })
);

Future Updates

  • Color Picker for changing elements' colors
  • Text elements on designs to be 'contentEditable' for inline responsive content editing
  • Additional Icons and SVG shapes to search and choose from
  • Create copies of other user's designs to use as templates
  • Stockphoto API with Unpslash
  • Uploading custom images

gwaphics's People

Contributors

breakfasting avatar dependabot[bot] avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gwaphics's Issues

screenshot

Please help me to create a screenshot , can not run node server for Puppeteer

User Auth

  • Backend: DB, model, controller, views
  • Redux Loop: ajax, actions, reducer
  • Presentational Components
  • Styling
    • When errors are displayed, the form adjusts properly
  • Smooth, bug free navigation
    • Login errors clears when switching from login form to sign up form (and vice-versa)
    • Errors should display for both /signup and/login.
  • Adequate and appropriate seeds
    • Demo Login Works

License

Would you mind adding a license please?

FSP To-Do List

Wiki Page Home

  • Is the first page you see upon entering the wiki
  • Contains a welcome message
  • Contains a link/placeholder for a link to the live page
  • All links in the right sidebar should contain each wiki page and link to the correct page
  • Correctly formatted
    • each wiki page is listed in bullet points
    • all links route the correct page

MVP List

  • Should have 7 MVPs.
    • 3 of those are User Auth, Heroku, and Production README.
    • The other 4 are from the MVP List or they have clarified them with you
  • Contains a description sentence of the app
  • Includes two to three detailed bullets on functionality and presentation of feature
  • At least one CRUD feature, which states what CRUD operations are planned (creation, reading, updating, deletion)
  • Estimates how long it will take the code each MVP
  • Correctly formatted
    • MVPs are listed in an ordered list
    • Each MVP is broken down into bullet points

Database Schema

  • Contains correct datatypes
  • Contains appropriate constraints/details
    • primary key
    • not null
    • unique
    • indexed
    • foreign key
  • Contains bullet points after the table that state which foreign keys will reference to which table, or references to the associations which will be made
    • foreign key and table name are lowercased, snake_cased and back_ticked
  • Correctly formatted
    • schema is written in a table format
    • the table's name are lowercased, snake_cased and back_ticked
    • the table header column names are bolded
    • columns names are lowercased and snaked_cased and back_ticked

Sample State

  • State shape is flat!
  • State's keys are camelCased
  • All keys within the values in the state are accessible in the schema
  • Correctly formatted
    • Sample state is rendered with triple backticks, and the language ```javascript...```). This will display the state as a code block instead of a giant line of text
    • Top level slices
      • entities
      • session
      • errors (here or in ui)
      • ui (if needed)
    • Should NOT have nested slices, aka comments inside of posts
      • Some info from other tables is ok, for instance:
        • the author username and imageurl for a post. basically any info that the user can't change
        • like count and a boolean on whether the user likes the post instead of a likes slice

Backend Routes

  • Contains the following sections: HTML, API Endpoints(Backend)
  • Each route has a description
  • API Endpoint routes contains wildcard variables written in snake_case
  • Routes does not contain superfluous routes
  • Have API routes that will allow the front end to get all info it needs and does not have unneeded routes:
    • probably doesn't need a GET likes api endpoint because that info comes through the post show

Frontend Routes

  • Frontend routes contains wildcard variables written in camelCase
  • Correctly formatted
    • Routes are displayed with inline coding text (backticks)

How to add newelements?

Hi
Is there any way we can add additional elements like line, arrow etc.
Also is there any way to set the properties like border, size , color of the element

PA Review: Folders

  • Users can create optional folders to hold designs
  • Users can update folder names
  • Users can delete folders, nullifying the design's foreign id
  • Users can move designs within folders

PA Review: Designs

  • Users can create designs
  • Users can put a variety of elements on their designs
  • Users can view a list of designs under their account
  • Users can edit/update their existing designs
  • BONUS: Users may change the positioning of elements or resize them via drag & drop

hello

hello,
how are you?
do you have script in php?

Ruby app version issue - mimemagic

Thank you for your amazing works.
I have a trouble to bundle app under the current Ruby.
Could you update your gem file?

When I google the error, rails version looks one of the issue but it is not easy to fix gem file considering compatibilities in my place.

gem 'rails', '~> 5.2.3'

Fetching gem metadata from https://rubygems.org/.......... 
Your bundle is locked to mimemagic (0.3.4) from rubygems repository
https://rubygems.org/ or installed locally, but that version can no longer be found in that source. That means the author of mimemagic (0.3.4) has removed it.

You'll need to update your bundle to a version other than mimemagic (0.3.4) that hasn't been removed in order to install.
Bundler Output: Fetching gem metadata from https://rubygems.org/..........
Your bundle is locked to mimemagic (0.3.4) from rubygems repository
https://rubygems.org/ or installed locally, but that version can no longer be found in that source. That means the author of mimemagic (0.3.4) has removed it.

You'll need to update your bundle to a version other than mimemagic (0.3.4) that hasn't been removed in order to install.

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.