• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    JavaScript
  • Created about 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A helper for visually debugging styles in CSS-in-JS

🙋‍♂️ Made by @thekitze

Other projects:

  • 🏫 React Academy - Interactive React and GraphQL workshops
  • 💌 Twizzy - A standalone app for Twitter DM
  • 💻 Sizzy - A tool for testing responsive design on multiple devices at once
  • 🤖 JSUI - A powerful UI toolkit for managing JavaScript apps

Zero To Shipped


Styles Debugger

A helper for visually debugging css-in-js styles.

  • Works both with template literals and objects.
  • It also works with inline styles but it won't show any text.

Made by Kitze

Install

yarn add styles-debugger

Demos

Basic usage

With template literals

import { debug } from 'styles-debugger';
import styled from 'styled-components';

const Header = styled.div`
  ${debug()};
`;

With objects

import { debug } from 'styles-debugger';
import emotion from 'react-emotion';

const Header = emotion('div')({
  ...debug()
});

Show text along the border

const Wrapper = styled.div`
  ${debug('Wrapper')};
`;

Show text + customize options

const Footer = styled.div`
  ${debug('Footer', { color: 'blue', debugWith: 'background' })};
`;

Available params for debug

debug(text: String, params: Object)

Each debug function call can override the default params object for the debugger with a custom object. So for example if for some element you would like to use specific options for debugging you can just pass them as the params parameter. See the available options.

Initialize custom instance

Instead of using the default debug function you can create your own debugger. Initialize it in some file and customize it the way you want.

import { CreateStylesDebugger } from 'styles-debugger';

const debug = CreateStylesDebugger({
  color: 'blue',
  borderSize: 3,
  position: 2,
  styles: {
    text: {
      color: 'red'
    }
  },
  debugWith: 'background'
});

export default debug;

Configuration options

  • enabled: if this is set to false debug mode will be turned off for all the components (default is true)
  • position: pick the corner position for the text: options are 1 | 2 | 3 | 4 (default is 1)
  • color: which should be a default color for the border of the element (by default it's a random color)
  • debugWith: what should be used for debugging the elements: border or background (default is border)
  • borderSize: if using border for debugging, specify the size of the border (default is 1)
  • showText: enable or disable showing text with pseudo elements for each component (default is true)
  • pseudoElement: which pseudo element to be used: after or before
  • styles: an object that can be passed to completely override the styles for element (the element that is debugged), and text (the pseudo element with the text).

More Repositories

1

JSUI

A powerful UI toolkit for managing JavaScript apps
JavaScript
4,244
star
2

react-hanger

A collection of useful React hooks
TypeScript
1,935
star
3

awesome-conference-practices

Did you like anything in particular about a conference? Let's make an awesome list 🎉
1,050
star
4

react-genie

A set of React components for animating elements as they scroll into the viewport
TypeScript
747
star
5

twizzle-landing

The landing page for Twizzle
JavaScript
644
star
6

mobx-router

A simple router for MobX + React apps
TypeScript
509
star
7

react-electron-example

An example of using React (create-react-app) with Electron
JavaScript
349
star
8

twizzle

A desktop app for Twitter DM & composing tweets from the menubar. Works on macOS, Windows, and Linux.
JavaScript
275
star
9

copy-lite

Copy to clipboard function with no dependencies
TypeScript
119
star
10

react-tiniest-router

The tiniest router for React, built with hooks
TypeScript
105
star
11

graphql-user

Reusable utility methods for GraphQL authentication in Node.js
TypeScript
104
star
12

react-long

A LongPress component for React
JavaScript
88
star
13

voice-command-list

Temporary repository for the voice-command-list project.
88
star
14

react-disable

A React component for disabling a section of an app
TypeScript
77
star
15

react-in-markdown

Render custom React components in Markdown
JavaScript
67
star
16

gtb

Gulp The Builder
JavaScript
40
star
17

twiwdev

This Week In Webdev
27
star
18

tired-of-webdev

26
star
19

kitze-js-helpers

JS helper functions
JavaScript
25
star
20

phone-browser

Source code for why-iphone-x
JavaScript
22
star
21

mobx-router-example

MobX router example
JavaScript
20
star
22

rttr

A tiny router for mobx-state-tree apps
JavaScript
13
star
23

shortcuts-to-icloud

Watch a folder with js shortcuts for Siri and transfer them to iCloud on every change
JavaScript
13
star
24

extension-twitter-no-views

Hides the annoying view count on Twitter with CSS
Shell
12
star
25

payment-gateway-calculator

A calculator for comparing fees and profit between different payment processor gateways
JavaScript
11
star
26

react-genie-emotion

Animations for using react-genie with emotion
TypeScript
9
star
27

styled-mixins

A collection of css-in-js mixins
TypeScript
9
star
28

apollo-react-user

Opinionated package for adding authentication to a React + Apollo app
TypeScript
8
star
29

kitze-sass-helpers

Helpful sass mixins for generating BEM syntax and making SASS development easier
CSS
6
star
30

react-plop

React templates for plop
JavaScript
6
star
31

prisma2-template

TypeScript
5
star
32

snakepong-gpt-4

snakepong game made by GPT-4
JavaScript
5
star
33

react-academy-labs-starter-2

JavaScript
4
star
34

mantine-layout-components

Horizontal, Vertical, and Grid components for Mantine
TypeScript
3
star
35

fakeGPT

generate fake screenshots of conversations with chatGPT
TypeScript
3
star
36

mobx-router-landing

A landing page for mobx-router
JavaScript
3
star
37

stylz

Mixins and helpers for writing styles in JS
JavaScript
3
star
38

react-genie-styled-components

A set of animations for using react-genie with styled-components
TypeScript
3
star
39

postgres-s3-backups

TypeScript
2
star
40

hello-github-actions

2
star
41

kitze

1
star
42

react-academy-graphpack-starter

JavaScript
1
star
43

electrontest

electron
JavaScript
1
star
44

kitze-react-plopfile

My plop setup for quickly generating react components
1
star