Coder Social home page Coder Social logo

handwritingfy's Introduction


Overview

Tired of webpages with 'perfect' typography, and pictures with all perfect lines/curves? Want to make them more natural, or sketchy? Give HandwritingFy a try by a few clicks.

HandwritingFy is a small toy which eanbles to change the style of webpages into handwritten like below screenshot,

xx

Production

chrome extension

Currently this tool has been published as a chrome extension, and you can install it at chrome web store.

The following screenshot is the extension console (popup), from which you can decide whether handwritingfying text and/or svg of webpages. There have also been around 20 styles available for texts.

extension console

You can also check out the demo video:

HandwritingFy

Javascript module for developers

If you want to integrate this handwriting style into your own webpage, simply put the following script tag at the end of the body tag of your html file. Refer to example for details.

<script src="https://cdn.jsdelivr.net/gh/TristanWYL/[email protected]/dist/handwritingfy.script.iife.min.js"></script>

Acknowledgement

This piece of work is inspred by this repository. Credits to its author @timqian.

Other topics

How to publish a javascaript module

Use jsdelivr.com and github to host the js module.

  1. Create a github release with a version number,

  2. Then the CDNed file could be accessible at https://cdn.jsdelivr.net/gh/TristanWYL/handwritingfy@version_number/dist/handwritingfy.script.iife.min.js.

    NOTE: Replace version number with the release number.

How to setup dev environment for Chrome Extension

This is my first time to develop a chrome extension, and it took me a while to setup the dev environment.

Tech stack: vitejs

Different from average web applications, a chrome extension can have more than one entry. Take HandwritingFy for example, it has:

  • console panel (popup window for users to play around the extension)
  • a js script which is executed under the hood of the extension

Extensions could have more entries, such as the option panel etc, but we do not have it here. After you go throough the following details, you will know how to add as many entries as you want.

Build

As vitejs does not support configs of building htmls and javascript modules in the same config file, we separate the configs into two config files, and apply them with two yarn build commands (vite build --config vite.config.js).

How to configure build for html

Vitejs recommends to use rollupOptions for building html entries,

rollupOptions: {
    input: {
      'index': resolve(__dirname, 'index.html'),
    }
  }

The full config file for HandwritingFy could be found at vite.config.popup.js

How to configure build for javascript

Vitejs recommends to use library mode for building javascript entries,

lib: {
  /** @desc executable for chrome extension */
  entry: resolve(__dirname, 'src/handwritingfy.chrome.js'),
  name: 'handwritingfy',
  formats: ['iife'],
  fileName: 'handwritingfy.chrome'
}

The full config file for HandwritingFy could be found at vite.config.chrome.js

Diable removing the dist

As two builds will output at the same directory dist/, we disable vitejs's auto clear of 'dist/' folder by adding an option in the config file,

build: {
  emptyOutDir: false,
}

so that two builds can exist at the same folder.

Copy

Now we should copy manifest.json and related assests like icons and images etc. into 'dist/', so that we can directly zip the dist folder and upload it as an extension package.

Configure a script into package.json, so that we can run it with yarn copy.

{
  "scripts": {
    "copy": "cp images/logo.png dist/logo.png && cp manifest.json dist/manifest.json"
  }
}

Wrapping up

Configure a wrapping up script into package.json, so that we can do all above work with a simple command yarn build,

{
  "scripts": {
    "build": "(rm -R ./dist/* || true) && yarn build-chrome-popup && yarn build-chrome-exec && yarn build-script && yarn copy"
  }
}

handwritingfy's People

Contributors

tristanwyl avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.