cssier 0.1.4 β†’ 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +150 -24
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,42 +1,168 @@
1
- # πŸ§‘β€πŸŽ¨CSSIER
1
+ Got it! Here's the updated README with the correct usage of the `<Button />` component from `cssier`:
2
2
 
3
- Inline styling for pseudoelements and pseudoclasses
3
+ # cssier
4
4
 
5
- ## Requirements
5
+ `cssier` is a React component library designed to simplify inline styling for pseudo-classes and pseudo-elements. With `cssier`, you can easily manage and apply custom styles for standard HTML and SVG elements, making your styling both dynamic and maintainable.
6
6
 
7
- - React >=18.2
8
- - A head element in your HTML document
9
- - Good judgements
7
+ ## Features
10
8
 
11
- ## Getting Started
9
+ - **Pre-built Components**: Import ready-to-use React components for HTML and SVG tags.
10
+ - **Advanced Styling**: Use the `useStylesheet` hook to manage custom styles for pseudo-classes and pseudo-elements.
11
+ - **TypeScript Support**: Includes TypeScript definitions for a smoother development experience.
12
+ - **Storybook Integration**: Automatically generates Storybook stories for visual testing and documentation.
13
+ - **Public Storybook**: Explore and interact with the components live at [cssier.danberman.dev](https://cssier.danberman.dev).
12
14
 
13
- 1. Install this module using `npm install cssier`
15
+ ## Installation
16
+
17
+ To install `cssier`, use npm, Yarn, or pnpm:
18
+
19
+ ```bash
20
+ npm install cssier
21
+ ```
22
+
23
+ or with Yarn:
24
+
25
+ ```bash
26
+ yarn add cssier
27
+ ```
28
+
29
+ or with pnpm:
30
+
31
+ ```bash
32
+ pnpm add cssier
33
+ ```
14
34
 
15
35
  ## Usage
16
36
 
17
- - Import the desired elements into your file, eg. `import {Div, A, H1} from 'cssier'`
18
- -
37
+ ### Importing Components
38
+
39
+ You can import pre-built React components for HTML and SVG tags from `cssier/components`:
40
+
41
+ ```jsx
42
+ import { Button, Svg } from 'cssier/components'
43
+
44
+ const MyComponent = () => (
45
+ <div>
46
+ <Button onClick={() => alert('Clicked!')}>Click Me</Button>
47
+ <Svg width="100" height="100">
48
+ <circle cx="50" cy="50" r="40" stroke="black" strokeWidth="3" fill="red" />
49
+ </Svg>
50
+ </div>
51
+ )
52
+ ```
53
+
54
+ ### Using the `useStylesheet` Hook
55
+
56
+ The `useStylesheet` hook from `cssier/hooks` allows you to apply styles for pseudo-classes (`:hover`, `:focus`, etc.) and pseudo-elements (`::before`, `::after`, etc.) directly to your components.
57
+
58
+ #### Values Returned by `useStylesheet`
59
+
60
+ The `useStylesheet` hook returns an array where:
61
+
62
+ - The first element is a unique CSS class ID that can be applied to the component.
63
+ - The second element is a string of CSS styles that were injected into the document. This is useful for debugging, though you typically won't need to use it in production.
19
64
 
20
- ## Main Scripts
65
+ ```jsx
66
+ import { useStylesheet } from 'cssier/hooks'
21
67
 
22
- Always prepending pnpm:
68
+ const CustomComponent = (props) => {
69
+ const { pseudo, pseudoId: id, ...rest } = props
70
+ const [pseudoId, css] = useStylesheet(pseudo, id)
23
71
 
24
- - `dev`: Bootstrap the Storybook preview with Hot Reload.
25
- - `build`: Builds the static storybook project.
26
- - `build:lib`: Builds the component library into the **dist** folder.
27
- - `lint:fix`: Applies linting based on the rules defined in **.eslintrc.js**.
28
- - `format:prettier`: Formats files using the prettier rules defined in **.prettierrc**.
29
- - `test`: Runs testing using watch mode.
30
- - `test:cov`: Runs testing displaying a coverage report.
72
+ return (
73
+ <>
74
+ <style>{css}</style>
75
+ <div {...rest} className={`${rest.className ?? ''}pseudoId`}>
76
+ Styled with pseudo-classes and pseudo-elements!
77
+ </div>
78
+ </>
79
+ )
80
+ }
81
+ ```
31
82
 
32
- ## Blog Post
83
+ #### Example of Custom Styling with Pseudo-classes
33
84
 
34
- I created a post explaning how to set up this library and publish it to a package registry! You can read it [here](https://igna.hashnode.dev/vite-react-typescript-component-library-template-setup-explanation).
85
+ ```jsx
86
+ <CustomComponent
87
+ pseudo={{
88
+ hover: { backgroundColor: 'lightblue' },
89
+ focus: { outline: '2px solid blue' },
90
+ }}
91
+ pseudoId="custom-id"
92
+ >
93
+ Hover or focus on me!
94
+ </CustomComponent>
95
+ ```
35
96
 
36
- ## Author
97
+ #### Example of Custom Styling with Pseudo-elements
37
98
 
38
- [Ignacio Miranda Figueroa](https://www.linkedin.com/in/ignacio-miranda-figueroa/)
99
+ ```jsx
100
+ <CustomComponent
101
+ pseudo={{
102
+ before: { content: '"Prefix"', color: 'gray' },
103
+ after: { content: '"Suffix"', color: 'gray' },
104
+ }}
105
+ pseudoId="custom-id"
106
+ >
107
+ Content with pseudo-elements
108
+ </CustomComponent>
109
+ ```
110
+
111
+ ### Dynamic Hover Color Example Using `<Button />`
112
+
113
+ Here's an example of using the `<Button />` component from `cssier` to create a button that changes its hover color each time it is clicked:
114
+
115
+ ```jsx
116
+ import { useState } from 'react'
117
+ import { Button } from 'cssier/components'
118
+
119
+ const DynamicButton = () => {
120
+ const [colorIndex, setColorIndex] = useState(0)
121
+ const colors = ['lightblue', 'lightcoral', 'lightgreen', 'lightgoldenrodyellow']
122
+
123
+ const handleClick = () => {
124
+ setColorIndex((prevIndex) => (prevIndex + 1) % colors.length)
125
+ }
126
+
127
+ return (
128
+ <Button
129
+ pseudo={{
130
+ hover: { backgroundColor: colors[colorIndex] },
131
+ }}
132
+ onClick={handleClick}
133
+ >
134
+ Click me to change hover color!
135
+ </Button>
136
+ )
137
+ }
138
+ ```
139
+
140
+ ### Props and Compatibility
141
+
142
+ The components provided by `cssier` accept all standard props for their HTML or SVG counterparts. For example, a `<Button>` component will accept props such as `onClick`, `disabled`, `type`, etc., just like a native HTML `<button>` element.
143
+
144
+ ## Public Storybook
145
+
146
+ Explore and interact with the `cssier` components in our publicly available Storybook at [cssier.danberman.dev](https://cssier.danberman.dev). This is a great way to see the components in action and understand how different styles and props affect their appearance.
147
+
148
+ ## Contributing
149
+
150
+ To contribute to `cssier`:
151
+
152
+ 1. Fork the repository.
153
+ 2. Create a new branch (`git checkout -b feature/your-feature`).
154
+ 3. Make your changes.
155
+ 4. Commit your changes (`git commit -am 'Add new feature'`).
156
+ 5. Push to the branch (`git push origin feature/your-feature`).
157
+ 6. Create a Pull Request on GitHub.
39
158
 
40
159
  ## License
41
160
 
42
- [MIT](LICENSE)
161
+ `cssier` is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
162
+
163
+ ## Additional Resources
164
+
165
+ - [GitHub Repository](https://github.com/DanBermanTech/cssier) – Source code and issue tracking.
166
+ - [Storybook Documentation](https://storybook.js.org/) – Learn how to use Storybook with your components.
167
+
168
+ Thank you for choosing `cssier`! We hope it makes managing your styles more intuitive and flexible.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cssier",
3
3
  "private": false,
4
- "version": "0.1.4",
4
+ "version": "0.1.5",
5
5
  "packageManager": "pnpm@8.4.0",
6
6
  "repository": {
7
7
  "type": "git",