Skip to content

Commit

Permalink
feat: add tailwind export
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanaden committed Jan 13, 2024
1 parent 357354d commit 6548bf7
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 39 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# solid-glow

## 0.0.5

### Patch Changes

- add tailwind export

## 0.0.4

### Patch Changes

- add tailwind export

## 0.0.3

### Patch Changes

- add tailwind to exports

## 0.0.2

### Patch Changes

- add tailwind package

## 0.0.1

### Patch Changes
Expand Down
78 changes: 67 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@

[![solid-glow](https://nodei.co/npm/solid-glow.png)](https://npmjs.org/package/solid-glow)

{{desc_of_lib}}
Add a mouse-tracing glow effect to React components.

> **Note** After using this template, you have to search and replace all `solid-glow` and similar strings
> with appropriate texts.
>
> `solid-glow` should be a **kebab-case** string representing the name of you monorepo.
>
> `{{desc_of_lib}}` should be a **Normal case** string with the description of the repository.
>
> `{{me}}` should be a **kebab-case** string from your profile URL.
![gif of glow effect](./media/glow.gif)

The glow effect will only work using the mouse as the pointer. Touch events will not trigger it.

## Quick start

Expand All @@ -41,6 +36,67 @@ pnpm add solid-glow

Use it:

```tsx
import solid-glow from 'solid-glow'
Wrap any number of `<Glow>` components in a `<GlowCapture>` which will be used to track the mouse location.

```jsx
<GlowCapture>
<span>This won't glow</span>
<Glow color="purple">
<span className="text-black glow:text-glow/50 glow:bg-red-100">
This will glow purple when the mouse is passed over
</span>
</Glow>
</GlowCapture>
```
Children of `<Glow>` can style themselves how to look when glowing. You might choose to leave some children unchanged, or highlight them with the `glow:` variant style.
The value of `color` will be available as a CSS variable `--glow-color`, as well as the Tailwind `glow` color.
You can pass any valid CSS color, including `hsl()` values etc.
Of course, you might choose to use any other color; you can leave out the `color` prop entirely.
## Tailwind
Add the tailwind plugin to unlock the `glow:` variant and `glow` color
`tailwind.config.js`
```js
module.exports = {
...
plugins: [
require('@codaworks/react-glow/tailwind')
]
}
```
As with all colors in Tailwind, you may add opacity by appending a percentage after the color, such as `bg-glow/20` for 20% opacity.
## Vanilla CSS
You can style the glow effect with vanilla CSS:
```jsx
<GlowCapture>
<span>This won't glow</span>
<Glow color="hsl(338.69 100% 48.04%)">
<span className="glowable-text">
This will glow pink when the mouse is passed over
</span>
</Glow>
</GlowCapture>
```

```css
.glowable-text {
color: black;
}

[glow] .glowable-text {
color: var(--glow-color);
}
```

## Attribution

SolidJS port of [react-glow](https://twitter.com/codepen/status/1696297659663888490).
Binary file modified dev/bun.lockb
Binary file not shown.
7 changes: 6 additions & 1 deletion dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
"dependencies": {
"@solidjs/start": "^0.4.9",
"highlight.js": "11.9.0",
"solid-glow": "^0.0.1",
"solid-glow": "^0.0.7",
"solid-js": "^1.8.11",
"vinxi": "0.1.2"
},
"engines": {
"node": ">=18"
},
"devDependencies": {
"autoprefixer": "^10.4.16",
"postcss": "^8.4.33",
"tailwindcss": "^3.4.1"
}
}
6 changes: 6 additions & 0 deletions dev/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
2 changes: 1 addition & 1 deletion dev/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const App: Component = () => {
<GlowCapture>
<span>This won't glow</span>
<Glow color="hsl(338.69 100% 48.04%)">
<span class="glowable-text">
<span class="text-black glow:text-glow">
This will glow pink when the mouse is passed over
</span>
</Glow>
Expand Down
12 changes: 4 additions & 8 deletions dev/src/main.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
Expand All @@ -11,11 +15,3 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}

.glowable-text {
color: black;
}

[glow] .glowable-text {
color: var(--glow-color);
}
8 changes: 8 additions & 0 deletions dev/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('tailwindcss').Config} */
export default {
content: ["./src/**/*.{html,js,jsx,ts,tsx}"],
theme: {
extend: {},
},
plugins: [require("solid-glow/tailwind")],
};
25 changes: 15 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solid-glow",
"version": "0.0.1",
"version": "0.0.7",
"description": "Add a mouse-tracing glow effect to Solid components",
"license": "MIT",
"author": "aidanaden",
Expand Down Expand Up @@ -28,19 +28,24 @@
"types": "./dist/index.d.ts",
"browser": {},
"exports": {
"solid": {
"development": "./dist/dev.jsx",
"import": "./dist/index.jsx"
},
"development": {
".": {
"solid": {
"development": "./dist/dev.jsx",
"import": "./dist/index.jsx"
},
"development": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/dev.js"
}
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/dev.js"
"default": "./dist/index.js"
}
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"./tailwind": {
"default": "./src/tailwind.js"
}
},
"typesVersions": {},
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"esModuleInterop": true,
"noEmit": true,
"isolatedModules": true,
"declaration": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
Expand Down
16 changes: 8 additions & 8 deletions tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ export default defineConfig((config) => {

const parsed_options = preset.parsePresetOptions(preset_options, watching);

if (!watching && !CI) {
const package_fields = preset.generatePackageExports(parsed_options);
// if (!watching && !CI) {
// const package_fields = preset.generatePackageExports(parsed_options);

console.log(
`package.json: \n\n${JSON.stringify(package_fields, null, 2)}\n\n`
);
// console.log(
// `package.json: \n\n${JSON.stringify(package_fields, null, 2)}\n\n`
// );

// will update ./package.json with the correct export fields
preset.writePackageJson(package_fields);
}
// // will update ./package.json with the correct export fields
// preset.writePackageJson(package_fields);
// }

return preset.generateTsupOptions(parsed_options);
});

0 comments on commit 6548bf7

Please sign in to comment.