Skip to content

Commit

Permalink
publish 0.0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon committed Jan 23, 2024
1 parent 2fd2af7 commit c13e8dc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
30 changes: 30 additions & 0 deletions packages/next-yak/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,36 @@ const Button = styled.button`
`;
```


## Build Time Constants

The downside of dynamic properties is that they require inline style attributes.
While this is not a problem for most cases, we can't use them for media queries.

`next-yak` allows you to define build time constants which can be used in your styles:

```jsx
import { styled } from 'next-yak';
import { breakpoints, spacings } from './constants.yak';

const Container = styled.div`
padding: ${spacings.md};
${breakpoints.md} {
padding: ${spacings.lg};
}
`;
```

| Feature | Code | Yak Constant files |
|:-----------------|:------------------------------------------------|:-----------------------------------------------|
| File Extension | `.js`, `.jsx`, `.tsx`, etc. | `.yak.js`, `.yak.jsx`, `.yak.tsx`, etc. |
| Runs at | Runtime (Node or Browser) | Compile time (Bundler) |
| Side effects || 🚫 |
| Yak Features | All (`styled`, `css`, ...) | 🚫 |


[Build time constants (video)](https://github.com/jantimon/next-yak/assets/4113649/6bdc44df-2996-40a3-9255-4b9ed0df464a)

## Todos:

next-yak is currently in the development phase, with several todos that must be completed before it is ready for production:
Expand Down
1 change: 0 additions & 1 deletion packages/next-yak/loaders/lib/getCssName.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ const getStyledComponentName = (taggedTemplateExpressionPath) => {
* @returns {string}
*/
function getMemberExpressionName(node) {
console.log(node.object, node.property.type);
if (
!node.object ||
!node.property ||
Expand Down
2 changes: 1 addition & 1 deletion packages/next-yak/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-yak",
"version": "0.0.23",
"version": "0.0.25",
"type": "module",
"types": "./dist/",
"exports": {
Expand Down

0 comments on commit c13e8dc

Please sign in to comment.