Releases: Bedrock-Layouts/Bedrock
Removing JavaScript from my Layout Library
A ResponsiveswitchAt
without all the JavaScript
Bedrock's Columns Component has always had the ability to switch to a stacking layout if you provided the switchAt
prop. The switchAt
prop lets the column component know at which size it should switch from columns to Stack. So nothing has really changed, except one major thing: It no longer requires JavaScript to do it. It's now done with just CSS. Here is an example where if you go below 60ch, it will automatically change to a stacking layout: https://codesandbox.io/s/vibrant-goldstine-bk7bt0?file=/src/App.tsx
What's Changed
- feat: remove JavaScript dependency on to switchAt by @Jarvis1010 in #1602
Full Changelog: https://github.com/Bedrock-Layouts/Bedrock/commits/@bedrock-layout/[email protected]
Breaking Bedrock
A detailed description of the motivations of this release can be read at https://non-traditional.dev/breaking-bedrock
in summary:
- Bedrock will no longer use styled-components. Instead, it will depend on its own Bedrock Layout CSS framework
- Bedrock has adopted open-props sizes as the default spacing
- prop-types have been dropped
- Named exports are now the standard across all packages
The one where we "use the platform"
In this release, we have refactored the internals of the Split
component, along with the split
CSS, to move away from the JavaScript to do the switchAt
logic and move all that to the CSS. It's also allowed me to implement a minItemWidth
prop that will allow you to set the minimum item width for the children.
Split
is also now responsive by default. The Split will automatically move to a Stack
layout if the minItemWidth cannot be maintained inline.
Thanks, and enjoy!
The one where we align the props
We've been a bit inconsistent here at Bedrock. Each component has been made in a vacuum, which means that we ended up with a couple of ways to say the same thing. In the Grid
component we had the minItemWidth
prop and in the ColumnDrop
we had the basis
prop. Both effectively said the same thing. We also had the Inline
Component that should have implemented this, but didn't.
So this release is doing just that. The Grid, ColumnDrop, and Inline components now have the same minItemWidth
prop. The ColumnDrop
will no longer have the basis
prop and inline will no longer default to having each of the children have a minimum width of fit-content
. This means breaking changes in the following components:
- Grid
- MasonryGrid
- Inline
- ColumnDrop
In addition, bedrock-layout-css
and the primitives
packages also got a major version bump due to the changes. I hope you enjoy this update.
What's Changed
- MinItem by @Jarvis1010 in #1344
Full Changelog: https://github.com/Bedrock-Layouts/Bedrock/commits/@bedrock-layout/[email protected]
“I Want to Break Free”
In a perfect world, every website will have a well-defined spacing scheme that you can use to have nice and consistent layouts. In the real world, applications we work on don't have well-defined spacing schemes, and sometimes we just need to use arbitrary spacing values in applications like this.
Unfortunately, Bedrock has forced all spaceing props, like gutter
and padding
to be based on a spacing scheme and did not have a way to allow arbitrary values. This works well in an ideal situation like a design system or an app with good spacing scheme in the style guide, but extremly difficult otherwise.
Breaking Free of the Spacing Scheme
With this release all gutter
and padding
values, in addition to the spacing scheme properties, will allow you to pass in any positive integer or valid CSSLength
value as a string. This even includes css custom properties wrapped in var, like this: var(--custom-properties)
. This release will now make Bedrock layout full achieve it's goal of being the "Lodash of web layouts" allowing you to use them in any application.
What's Changed
- Make-CSS-length-universal by @Jarvis1010 in #1163
Full Changelog: https://github.com/Bedrock-Layouts/Bedrock/commits/@bedrock-layout/[email protected]
New Package: register-resize-callback
The ResizeObserver
API is now fully supported, but I would argue that the API is not super intuitive to how it was intended to work. It is intended to be instantiated with a callback that will take multiple resized elements. Then you can use the ResizeObserver to observe multiple DOM Elements, and call the supplied callback will be called with an array of elements that were resized in this tick. From there you can loop through the elements and make decisions based on them.
In practice, most people want to have one callback per node and so they end up creating multiple ResizeObservers each with their own unique callback just to observe a single node. This is ok for one or two things, but this can start to create performance issues the more you create.
register-resize-callback
I decided to create a wrapper that let's you use a ResizeObserver the way you want to. You simply register a callback for the node you want to observe and it returns a cleanup function, like this:
import { init, registerCallback } from '@bedrock-layout/register-resize-callback';
// used to allow you to safely initialize observer in the browser and not on the server
init()
const callback = (entry) => {
console.log(entry);
};
const callbackObj = {
current: (entry) => {
console.log(entry);
}
};
const header = document.querySelector('header');
const article = document.querySelector('article');
//register a callback for a node
const cleanupHeader = registerCallback(header, callback)
const cleanupArticle = registerCallback(article, callbackObj)
callbackObj.current = (entry)=>{
console.log('new callback', entry);
};
//unregister the callback
cleanupHeader()
cleanupArticle()
Go check it out.
What's Changed
- feat(register-resize-callback): publish resize callback package by @Jarvis1010 in #1155
- Fix publish ci by @Jarvis1010 in #1156
- build(actions): fix pipeline by @Jarvis1010 in #1157
Full Changelog: https://github.com/Bedrock-Layouts/Bedrock/commits/@bedrock-layout/[email protected]
You Can Ratio this Release
Now that aspect-ratio
is fully supported across the big 3, it makes more sense to align the Frame
component with the CSS-only version that accepts a string in the width/height
format. The Frame
component will continue to support the two number array for the foreseeable future, but the string format should be the preferred way to use the ratio
prop.
What's Changed
- feat(frame): allow ratio string in
ratio
prop by @Jarvis1010 in #1130
Full Changelog: https://github.com/Bedrock-Layouts/Bedrock/commits/@bedrock-layout/[email protected]
@bedrock-layout/[email protected]
One Package to rule them all
Each of the primitives is independently versioned and installable. There are many benefits to doing this, but it is also nice to have a single install point if you know that you will be using all or most of the primitives.
The @bedrock-layout/primitives
package includes all the primitives, hooks, and spacing-constants utilities in a single package as named exports.
Usage
import { Stack, Inline, Split, Cover, Frame } from '@bedrock-layout/primitives';
export function Hero() {
return (
<Stack>
<Inline>{/* */}</Inline>
<Split>
<Cover>
<Stack>
<h1>{/* */}</h1>
<p>{/* */}</p>
<Inline>
<button>{/* */}</button>
<button>{/* */}</button>
</Inline>
</Stack>
</Cover>
<Frame>
<img />
</Frame>
</Split>
</Stack>
);
}
What's Changed
- Feature/Primitives by @Jarvis1010 in #1116
Full Changelog: https://github.com/Bedrock-Layouts/Bedrock/commits/@bedrock-layout/[email protected]
Type safety for properties that take a CSS length
Up until now, props that accepted a CSS length as a string never had any proper type-safety. For example, one could set the minItemWidth
to 100jibjabs
on the Grid
component and nothing would warn you that this is incorrect.
Luckily that is in our past. Bedrock has adopted much better type-safe types for anything that should be a CSS length. Now props, like Grid
's minItemWidth
prop, will show an error if the format of the string isn't either <number><CSS unit | percentage>
or var(<custom prop name>)
. The following components will have adopted this:
Grid
-> minItemWidth
ColumnDrop
-> basis
Center
-> maxWidth
Cover
-> minHeight
What's Changed
- Feature/csslength by @Jarvis1010 in #1113
Full Changelog: https://github.com/Bedrock-Layouts/Bedrock/commits/@bedrock-layout/[email protected]
Better Typing for CSS Length
We are adding better typing for CSS lengths.
Let's get all this out of the way so we don't have to worry about it again. Sorry
What's Changed
- Grid by @Jarvis1010 in #1
- update default minItemWidth by @Jarvis1010 in #2
- add favicon and meta data to website by @Jarvis1010 in #3
- Split by @Jarvis1010 in #4
- add links to storybook by @Jarvis1010 in #5
- Appboundary by @Jarvis1010 in #6
- Center by @Jarvis1010 in #7
- Utils by @Jarvis1010 in #8
- Use forwarded ref by @Jarvis1010 in #9
- finish docs for full release by @Jarvis1010 in #10
- Use container query by @Jarvis1010 in #11
- Switcher by @Jarvis1010 in #12
- Use stateful ref by @Jarvis1010 in #13
- Use media query by @Jarvis1010 in #14
- useMatchMedia by @Jarvis1010 in #15
- update documentation by @Jarvis1010 in #16
- Cross browser check by @Jarvis1010 in #17
- Inlinecluster by @Jarvis1010 in #18
- Fix typo on homepage by @mxstbr in #19
- Create CODE_OF_CONDUCT.md by @Jarvis1010 in #20
- Add column switcher by @Jarvis1010 in #21
- Cover by @Jarvis1010 in #22
- remove cover by @Jarvis1010 in #23
- Frame by @Jarvis1010 in #25
- Tslint by @Jarvis1010 in #26
- update dependencies by @Jarvis1010 in #27
- Bump lodash from 4.17.15 to 4.17.19 by @dependabot in #28
- Update styled-components.mdx by @talmasc in #29
- Update primitives.mdx by @talmasc in #30
- Update InlineCluster.mdx by @talmasc in #31
- Update useStatefulRef.mdx by @talmasc in #32
- Update InlineCluster.mdx by @talmasc in #33
- Update useMediaQuery.mdx by @aerawk in #34
- Bump @reach/visually-hidden from 0.9.0 to 0.10.4 by @dependabot in #39
- Bump microbundle from 0.11.0 to 0.12.3 by @dependabot in #37
- Bump @storybook/addon-a11y from 5.3.19 to 6.0.10 by @dependabot in #40
- Bump @storybook/addon-actions from 5.3.19 to 6.0.10 by @dependabot in #41
- Bump @storybook/react from 5.3.19 to 6.0.10 by @dependabot in #35
- Bump @storybook/addon-docs from 5.3.19 to 6.0.10 by @dependabot in #38
- Bump @storybook/addon-links from 5.3.19 to 6.0.10 by @dependabot in #36
- Add static checks by @Jarvis1010 in #42
- Css reset by @Jarvis1010 in #45
- Bump jest from 25.5.4 to 26.4.0 by @dependabot in #43
- Bump babel-jest from 25.5.1 to 26.3.0 by @dependabot in #44
- Bump jest-styled-components from 7.0.2 to 7.0.3 by @dependabot in #48
- Bump @storybook/addon-a11y from 6.0.12 to 6.0.16 by @dependabot in #51
- Bump @storybook/addon-knobs from 6.0.12 to 6.0.16 by @dependabot in #52
- Bump @storybook/addon-docs from 6.0.12 to 6.0.16 by @dependabot in #53
- Bump @storybook/addons from 6.0.12 to 6.0.16 by @dependabot in #54
- Bump @storybook/react from 6.0.12 to 6.0.16 by @dependabot in #59
- Bump jest from 26.4.0 to 26.4.2 by @dependabot in #58
- Bump @reach/visually-hidden from 0.10.4 to 0.11.0 by @dependabot in #57
- Bump @storybook/addon-links from 6.0.12 to 6.0.16 by @dependabot in #56
- Bump @storybook/addon-actions from 6.0.12 to 6.0.16 by @dependabot in #55
- Bump @storybook/react from 6.0.16 to 6.0.17 by @dependabot in #64
- Bump @storybook/addon-a11y from 6.0.16 to 6.0.18 by @dependabot in #67
- Bump @storybook/addon-docs from 6.0.16 to 6.0.18 by @dependabot in #65
- Bump prettier from 2.0.5 to 2.1.0 by @dependabot in #61
- Bump @storybook/addons from 6.0.16 to 6.0.18 by @dependabot in #66
- Bump prettier from 2.1.0 to 2.1.1 by @dependabot in #71
- Bump @storybook/react from 6.0.17 to 6.0.18 by @dependabot in #70
- Bump @storybook/addon-links from 6.0.16 to 6.0.18 by @dependabot in #69
- Bump @storybook/addon-actions from 6.0.16 to 6.0.18 by @dependabot in #68
- Bump lint-staged from 10.2.11 to 10.2.13 by @dependabot in #74
- Bump @storybook/react from 6.0.18 to 6.0.19 by @dependabot in #72
- Bump @storybook/addon-a11y from 6.0.18 to 6.0.19 by @dependabot in #75
- Bump @storybook/addon-knobs from 6.0.16 to 6.0.19 by @dependabot in #73
- Bump @storybook/addons from 6.0.18 to 6.0.19 by @dependabot in #76
- add mock for switcher by @Jarvis1010 in #82
- Bump @storybook/addon-knobs from 6.0.19 to 6.0.20 by @dependabot in #81
- Bump @babel/core from 7.11.1 to 7.11.4 by @dependabot in #80
- Bump @storybook/addon-info from 5.3.19 to 5.3.21 by @dependabot in #79
- Bump @storybook/addons from 6.0.19 to 6.0.20 by @dependabot in #78
- Bump @storybook/addon-a11y from 6.0.19 to 6.0.20 by @dependabot in #77
- Add mocking by @Jarvis1010 in #92
- Bump @storybook/addon-docs from 6.0.18 to 6.0.21 by @dependabot in #91
- Bump @storybook/addon-links from 6.0.18 to 6.0.21 by @dependabot in #90
- Bump @storybook/addon-actions from 6.0.18 to 6.0.21 by @dependabot in #89
- Bump @types/react from 16.9.46 to 16.9.49 by @dependabot in #88
- Bump @storybook/addons from 6.0.20 to 6.0.21 by @dependabot in #87
- Test coverage by @Jarvis1010 in #98
- Bump @babel/preset-env from 7.11.0 to 7.11.5 by @dependabot in #97
- Bump @storybook/addon-knobs from 6.0.20 to 6.0.21 by @dependabot in #96
- Bump @storybook/addon-a11y from 6.0.20 to 6.0.21 by @dependabot in #95
- Bump lint-staged from 10.2.13 to 10.3.0 by @dependabot in #94
- Bump @babel/core from 7.11.4 to 7.11.6 by @dependabot in #93
- update inline cluster css by @Jarvis1010 in #99
- fix classname bug by @Jarvis1010 in #100
- Bump husky from 4.2.5 to 4.3.0 by @dependabot in #105
- Bump styled-components from 5.1.1 to 5.2.0 by @dependabot in #104
- Bump @storybook/react from 6.0.19 to 6.0.21 by @dependabot in #103
- Bump @types/styled-components from 5.1.2 to 5.1.3 by @dependabot in #102
- Bump @reach/visually-hidden from 0.11.0 to 0.11.1 by @dependabot in #101
- Bump @mdx-js/mdx from 1.6.16 ...