Giter Site home page Giter Site logo

css-compare's Introduction

Computed CSS Style Comparator

This provides a utility in the form of a Docker/Podman container that fetches two different copies of a page, selects a (unique) element on that page, and then computes the difference between the value of getComputedStyle when run on that same element on both pages. Additionally, it checks for significant differences between the innerHTML properties of the elements being compared.

This is intended to be useful to isolate style changes where complex changes are involved between different revisions of an application, e.g. when working with Rails asset pipeline when upgrading a Rails project.

Usage

Create a file named config.mjs modeled on the provided example; the element attribute of the config object should be a CSS selector that uniquely matches an element on the page in question. sites should be a two-element array using the URLs of a current site (e.g. production) and of a site where you are querying changes.

Waiting for elemments to be added to the page

Add a waitForSelector selector to the configuration; the checker will wait until an element matching the selector has been added to the page; this will allow JavaScript that modifies the page after it's been loaded to run.

Alternately, you can add waitForFunction which is a string containing a JS expression that must evaluate to true before the checker will evaluate the target element. This is more flexible and error-prone possibly than the waitForSelector. If both are present, then the function/expression will be used and waitForSelector value will be ignored.

Building

After you have created (or updated) the config.mjs and/or the fetch.mjs files, run:

$ docker build . -t css_compare

Running

$ docker run -it --rm css_compare

Tip For Accessing Sites running on Local Containers

You may be investigating the styling of a locally modified site running in a container. Assuming you've used defaults for networks, that site should be available to the container run by this project at the URL http://host.containers.internal:{port exposed to host}, e.g. http://host.containers.internal:3000 for a Rails app running under Puma in another container. Note that you may need to adjust config.hosts for that app (e.g. in config/environments/development.rb) to allow Rails 6+ to serve it at that hostname.

css-compare's People

Contributors

adjam avatar

Watchers

 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.