Skip to content

Commit 3d5a947

Browse files
author
John Richard Chipps-Harding
authored
Initial Stab (#3)
* Initial Stab * remove test * misc
1 parent 77aeeca commit 3d5a947

File tree

12 files changed

+6122
-17418
lines changed

12 files changed

+6122
-17418
lines changed

.github/workflows/pr.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ jobs:
2626
npm ci
2727
npm run build --if-present
2828
npm run lint
29-
npm test
3029
env:
3130
CI: true

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
npm ci
2626
npm run build --if-present
2727
npm run lint
28-
npm test
2928
env:
3029
CI: true
3130

CODE_OF_CONDUCT.md

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
## Our Pledge
44

5-
In the interest of fostering an open and welcoming environment, we as
6-
contributors and maintainers pledge to making participation in our project and
7-
our community a harassment-free experience for everyone, regardless of age, body
8-
size, disability, ethnicity, sex characteristics, gender identity and expression,
9-
level of experience, education, socio-economic status, nationality, personal
10-
appearance, race, religion, or sexual identity and orientation.
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
116

127
## Our Standards
138

@@ -22,55 +17,32 @@ include:
2217

2318
Examples of unacceptable behavior by participants include:
2419

25-
- The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
20+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
2721
- Trolling, insulting/derogatory comments, and personal or political attacks
2822
- Public or private harassment
29-
- Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
- Other conduct which could reasonably be considered inappropriate in a
32-
professional setting
23+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
24+
- Other conduct which could reasonably be considered inappropriate in a professional setting
3325

3426
## Our Responsibilities
3527

36-
Project maintainers are responsible for clarifying the standards of acceptable
37-
behavior and are expected to take appropriate and fair corrective action in
38-
response to any instances of unacceptable behavior.
28+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
3929

40-
Project maintainers have the right and responsibility to remove, edit, or
41-
reject comments, commits, code, wiki edits, issues, and other contributions
42-
that are not aligned to this Code of Conduct, or to ban temporarily or
43-
permanently any contributor for other behaviors that they deem inappropriate,
44-
threatening, offensive, or harmful.
30+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
4531

4632
## Scope
4733

48-
This Code of Conduct applies both within project spaces and in public spaces
49-
when an individual is representing the project or its community. Examples of
50-
representing a project or community include using an official project e-mail
51-
address, posting via an official social media account, or acting as an appointed
52-
representative at an online or offline event. Representation of a project may be
53-
further defined and clarified by project maintainers.
34+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
5435

5536
## Enforcement
5637

57-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58-
reported by contacting the project team at [email protected]. All
59-
complaints will be reviewed and investigated and will result in a response that
60-
is deemed necessary and appropriate to the circumstances. The project team is
61-
obligated to maintain confidentiality with regard to the reporter of an incident.
62-
Further details of specific enforcement policies may be posted separately.
38+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
6339

64-
Project maintainers who do not follow or enforce the Code of Conduct in good
65-
faith may face temporary or permanent repercussions as determined by other
66-
members of the project's leadership.
40+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
6741

6842
## Attribution
6943

70-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71-
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
44+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
7245

7346
[homepage]: https://www.contributor-covenant.org
7447

75-
For answers to common questions about this code of conduct, see
76-
https://www.contributor-covenant.org/faq
48+
For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq

CONTRIBUTING.md

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,27 @@
22

33
I'm really happy that you're interested in helping out with this little project.
44

5-
As this is very early days for the project there's not a lot in the way of
6-
resources, but please check out the [documentation](./README.md), and also the
7-
[list of issues](https://github.com/phantomstudios/PACKAGE-NAME/issues).
5+
As this is very early days for the project there's not a lot in the way of resources, but please check out the [documentation](./README.md), and also the [list of issues](https://github.com/phantomstudios/css-components/issues).
86

97
Please submit an issue if you need help with anything.
108

11-
We have a [code of conduct](./CODE_OF_CONDUCT.md) so please make sure you follow
12-
it.
13-
14-
## Testing
15-
16-
Testing is performed using `jest` and is tested on Windows, Linux and MacOS with
17-
Node 10 and 12 runtimes. For a PR to be considered all these environments need to
18-
pass. Testing is automated using GitHub Actions CI.
9+
We have a [code of conduct](./CODE_OF_CONDUCT.md) so please make sure you follow it.
1910

2011
## Submitting changes
2112

2213
Please send a
23-
[GitHub Pull Request to PACKAGE-NAME](https://github.com/phantomstudios/PACKAGE-NAME/pull/new/master)
24-
with a clear list of what you've done (read more about
25-
[pull requests](https://help.github.com/en/articles/about-pull-requests)). When you send a pull
26-
request, please make sure you've covered off all the points in the template.
14+
[GitHub Pull Request to css-components](https://github.com/phantomstudios/css-components/pull/new/master) with a clear list of what you've done (read more about [pull requests](https://help.github.com/en/articles/about-pull-requests)). When you send a pull request, please make sure you've covered off all the points in the template.
2715

28-
Make sure you've read about our workflow (below); in essence make sure each Pull
29-
Request is atomic but don't worry too much about the commits themselves as we use
30-
squash-and-merge.
16+
Make sure you've read about our workflow (below); in essence make sure each Pull Request is atomic but don't worry too much about the commits themselves as we use squash-and-merge.
3117

3218
## Our workflow
3319

34-
We use [GitHub flow](https://guides.github.com/introduction/flow/); it's a lot
35-
like git-flow but simpler and more forgiving. We use the `squash and merge`
36-
strategy to merge Pull Requests.
20+
We use [GitHub flow](https://guides.github.com/introduction/flow/); it's a lot like git-flow but simpler and more forgiving. We use the `squash and merge` strategy to merge Pull Requests.
3721

3822
In effect this means:
3923

40-
- Don't worry about individual commits. They will be preserved, but not on the
41-
main `master` branch history, so feel free to commit early and often, using
42-
git as a save mechanism.
43-
- Your Pull Request title and description become very important; they are the
44-
history of the master branch and explain all the changes.
45-
- You ought to be able to find any previous version easily using GitHub tabs, or
46-
[Releases](https://github.com/phantomstudios/PACKAGE-NAME/releases)
24+
- Don't worry about individual commits. They will be preserved, but not on the main `master` branch history, so feel free to commit early and often, using git as a save mechanism.
25+
- Your Pull Request title and description become very important; they are the history of the master branch and explain all the changes.
26+
- You ought to be able to find any previous version easily using GitHub tabs, or [Releases](https://github.com/phantomstudios/css-components/releases)
4727

4828
Thanks, John Chipps-Harding

README.md

Lines changed: 132 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,171 @@
1-
# PACKAGE-NAME
1+
# @phntms/css-components
22

33
[![NPM version][npm-image]][npm-url]
44
[![Actions Status][ci-image]][ci-url]
55
[![PR Welcome][npm-downloads-image]][npm-downloads-url]
66

7-
Package one-liner overview.
7+
A simple, lightweight, and customizable CSS components library that lets you wrap your css styles in a component-like structure. Inspired by css-in-js libraries like [styled-components](https://styled-components.com/) and [stitches](https://stitches.dev/).
88

99
## Introduction
1010

11-
Package introduction, couple of paragraphs.
11+
At its core, css-components is a simple wrapper around standard CSS. It allows you to write your CSS how you wish then compose them into a component ready to be used in React.
1212

13-
```javascript
14-
import useLibrary from "@phntms/PACKAGE-NAME";
13+
Here is a minimal example of a button component with an optional variant:
1514

16-
const { something } = useLibrary({
17-
argument1: "something",
18-
argument2: "something else",
15+
```ts
16+
import { styled } from "@phntms/css-components";
17+
import css from "./styles.module.css";
18+
19+
export const Button = styled("button", css.root, {
20+
primary: {
21+
true: css.primary,
22+
},
1923
});
2024
```
2125

26+
This outputs a nice clean component that can be used in React:
27+
28+
```tsx
29+
import { Button } from "./Button";
30+
31+
export const App = () => (
32+
<div>
33+
<Button>Default</Button>
34+
<Button primary>Primary</Button>
35+
</div>
36+
);
37+
```
38+
2239
## Installation
2340

2441
Install this package with `npm`.
2542

2643
```bash
27-
npm i @phntms/PACKAGE-NAME
44+
npm i @phntms/css-components
2845
```
2946

3047
## Usage
3148

32-
Example 1 description.
49+
Here is a full example of a button component with an optional variant called `primary`:
3350

34-
```JSX
35-
import React from 'react';
36-
import useLibrary from '@phntms/PACKAGE-NAME';
51+
components/Button/styles.module.css
3752

38-
const SomeExample = () = {
39-
const { something } = useApi({
40-
argument1: "something",
41-
argument2: "something else",
42-
});
53+
```css
54+
.root {
55+
background-color: grey;
56+
border-radius: 4px;
57+
}
4358

44-
return (
45-
<>
46-
<h1>Result</h2>
47-
<p>{something}</p>
48-
</>
49-
);
59+
.primary {
60+
background-color: black;
5061
}
5162
```
5263

53-
Example 2 description.
64+
components/Button/styles.ts
65+
66+
```ts
67+
import { styled } from "@phntms/css-components";
68+
import css from "./styles.module.css";
5469

55-
```JSX
56-
import React from 'react';
57-
import useLibrary from '@phntms/PACKAGE-NAME';
70+
export const StyledButton = styled("button", css.root, {
71+
primary: {
72+
true: css.primary,
73+
},
74+
});
75+
```
5876

59-
const SomeExample2 = () = {
60-
const { something } = useApi({
61-
argument1: "something",
62-
argument2: "something else",
63-
});
77+
components/Button/index.tsx
6478

65-
return (
66-
<>
67-
<h1>Result</h2>
68-
<p>{something}</p>
69-
</>
70-
);
79+
```tsx
80+
import { StyledButton } from "./styles.ts";
81+
82+
interface Props {
83+
title: string;
84+
onClick: () => void;
85+
primary?: boolean;
7186
}
87+
88+
export const Button = ({ title, onClick, primary }: Props) => (
89+
<StyledButton onClick={onClick} primary={primary}>
90+
{title}
91+
</StyledButton>
92+
);
93+
```
94+
95+
## The variants config object
96+
97+
The variants config object is a simple object that allows you to define the variants that your component supports. Each variant is a key in the object and the value is an object that defines the possible values(css classes) for that variant.
98+
99+
```tsx
100+
const StyledButton = styled("button", css.root, {
101+
big: {
102+
// Boolean values are supported
103+
true: css.big,
104+
},
105+
color: {
106+
// String values are supported
107+
primary: css.primary,
108+
secondary: css.secondary,
109+
},
110+
size: {
111+
// Number values are supported
112+
1: css.size1,
113+
2: css.size2,
114+
},
115+
});
72116
```
73117

74-
## API
118+
## Compound Variants
119+
120+
For more complex variant setups you can use the compound variants argument to define what styles should be applied when multiple variants are used.
121+
122+
```tsx
123+
const StyledButton = styled(
124+
"button",
125+
css.root,
126+
{
127+
border: {
128+
true: css.bordered,
129+
},
130+
color: {
131+
primary: css.primary,
132+
secondary: css.secondary,
133+
},
134+
},
135+
[
136+
{
137+
border: true,
138+
color: "primary",
139+
css: css.blueBorder,
140+
},
141+
{
142+
border: true,
143+
color: "secondary",
144+
css: css.greyBorder,
145+
},
146+
]
147+
);
148+
```
75149

76-
### Input
150+
## Other
77151

78-
- `argument1` : Required - Description of argument.
79-
- `argument2` : Optional - Description of argument.
152+
Wherever you specify a css selector, you can also pass in an array of classes to help composing and reusing styles.
80153

81-
### Output
154+
```tsx
155+
import { styled } from "@phntms/css-components";
156+
import shared from "../sharedstyles.module.css";
157+
import css from "./styles.module.css";
82158

83-
- `something`: Description of output.
159+
const Link = styled("a", [shared.link, shared.fontNormal, css.root], {
160+
big: {
161+
true: [css.big, shared.fontBold],
162+
},
163+
});
164+
```
84165

85-
[npm-image]: https://img.shields.io/npm/v/@phntms/PACKAGE-NAME.svg?style=flat-square&logo=react
86-
[npm-url]: https://npmjs.org/package/@phntms/PACKAGE-NAME
87-
[npm-downloads-image]: https://img.shields.io/npm/dm/@phntms/PACKAGE-NAME.svg
88-
[npm-downloads-url]: https://npmcharts.com/compare/@phntms/PACKAGE-NAME?minimal=true
89-
[ci-image]: https://github.com/phantomstudios/PACKAGE-NAME/workflows/test/badge.svg
90-
[ci-url]: https://github.com/phantomstudios/PACKAGE-NAME/actions
166+
[npm-image]: https://img.shields.io/npm/v/@phntms/css-components.svg?style=flat-square&logo=react
167+
[npm-url]: https://npmjs.org/package/@phntms/css-components
168+
[npm-downloads-image]: https://img.shields.io/npm/dm/@phntms/css-components.svg
169+
[npm-downloads-url]: https://npmcharts.com/compare/@phntms/css-components?minimal=true
170+
[ci-image]: https://github.com/phantomstudios/css-components/workflows/test/badge.svg
171+
[ci-url]: https://github.com/phantomstudios/css-components/actions

SUPPORT.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# PACKAGE-NAME Support
1+
# css-components Support
22

3-
For _questions_ on how to use `PACKAGE-NAME` or what went wrong when you tried something, our primary resource is by opening a
4-
[GitHub Issue](https://github.com/phantomstudios/PACKAGE-NAME/issues), where you can get help from developers.
3+
For _questions_ on how to use `css-components` or what went wrong when you tried something, our primary resource is by opening a [GitHub Issue](https://github.com/phantomstudios/css-components/issues), where you can get help from developers.

0 commit comments

Comments
 (0)