Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add box package #1067

Merged
merged 12 commits into from
Nov 14, 2023
Merged

feat: add box package #1067

merged 12 commits into from
Nov 14, 2023

Conversation

Niznikr
Copy link
Contributor

@Niznikr Niznikr commented Oct 31, 2023

Summary

First pass at a box component using rainbow-sprinkles. Nice that is allows us to use our vars package to map to our tokens. The built CSS is only 1.48 kB thanks to dynamic inlining CSS custom properties.

Screenshots (if appropriate):

Screenshot 2023-10-31 at 11 35 51 AM Screenshot 2023-10-31 at 11 37 00 AM

Copy link

changeset-bot bot commented Oct 31, 2023

🦋 Changeset detected

Latest commit: eb76380

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@launchpad-ui/box Minor
@launchpad-ui/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Oct 31, 2023

Size Change: +29 B (0%)

Total Size: 188 kB

Filename Size Change
packages/core/dist/index.es.js 1.14 kB +10 B (+1%)
packages/core/dist/index.js 1.53 kB +18 B (+1%)
packages/tokens/dist/index.es.js 2.57 kB +1 B (0%)
ℹ️ View Unchanged
Filename Size
packages/alert/dist/index.es.js 1.37 kB
packages/alert/dist/index.js 1.44 kB
packages/alert/dist/style.css 1.56 kB
packages/avatar/dist/index.es.js 1.16 kB
packages/avatar/dist/index.js 1.23 kB
packages/avatar/dist/style.css 467 B
packages/banner/dist/index.es.js 644 B
packages/banner/dist/index.js 714 B
packages/banner/dist/style.css 548 B
packages/box/dist/index.es.js 4.69 kB
packages/box/dist/index.js 4.78 kB
packages/box/dist/style.css 1.5 kB
packages/button/dist/index.es.js 1.63 kB
packages/button/dist/index.js 1.71 kB
packages/button/dist/style.css 3.72 kB
packages/card/dist/index.es.js 707 B
packages/card/dist/index.js 775 B
packages/card/dist/style.css 758 B
packages/chip/dist/index.es.js 679 B
packages/chip/dist/index.js 749 B
packages/chip/dist/style.css 899 B
packages/clipboard/dist/index.es.js 1.51 kB
packages/clipboard/dist/index.js 1.59 kB
packages/clipboard/dist/style.css 837 B
packages/collapsible/dist/index.es.js 856 B
packages/collapsible/dist/index.js 926 B
packages/collapsible/dist/style.css 94 B
packages/columns/dist/index.es.js 619 B
packages/columns/dist/index.js 692 B
packages/columns/dist/style.css 354 B
packages/counter/dist/index.es.js 335 B
packages/counter/dist/index.js 399 B
packages/counter/dist/style.css 263 B
packages/data-table/dist/index.es.js 2.47 kB
packages/data-table/dist/index.js 2.53 kB
packages/data-table/dist/style.css 388 B
packages/drawer/dist/index.es.js 1.73 kB
packages/drawer/dist/index.js 2.29 kB
packages/drawer/dist/style.css 580 B
packages/dropdown/dist/index.es.js 1.15 kB
packages/dropdown/dist/index.js 1.21 kB
packages/filter/dist/index.es.js 2.3 kB
packages/filter/dist/index.js 2.38 kB
packages/filter/dist/style.css 1.01 kB
packages/focus-trap/dist/index.es.js 270 B
packages/focus-trap/dist/index.js 333 B
packages/form/dist/index.es.js 4.23 kB
packages/form/dist/index.js 4.34 kB
packages/form/dist/style.css 2.76 kB
packages/icons/dist/index.es.js 1.35 kB
packages/icons/dist/index.js 1.42 kB
packages/icons/dist/style.css 528 B
packages/inline-edit/dist/index.es.js 1.58 kB
packages/inline-edit/dist/index.js 1.66 kB
packages/inline-edit/dist/style.css 343 B
packages/inline/dist/index.es.js 565 B
packages/inline/dist/index.js 637 B
packages/inline/dist/style.css 299 B
packages/markdown/dist/index.es.js 960 B
packages/markdown/dist/index.js 1.03 kB
packages/markdown/dist/style.css 241 B
packages/menu/dist/index.es.js 3.56 kB
packages/menu/dist/index.js 3.64 kB
packages/menu/dist/style.css 1.23 kB
packages/modal/dist/index.es.js 3.03 kB
packages/modal/dist/index.js 3.59 kB
packages/modal/dist/style.css 1.04 kB
packages/navigation/dist/index.es.js 2.79 kB
packages/navigation/dist/index.js 2.86 kB
packages/navigation/dist/style.css 1.26 kB
packages/overlay/dist/index.es.js 1 kB
packages/overlay/dist/index.js 1.06 kB
packages/pagination/dist/index.es.js 1.17 kB
packages/pagination/dist/index.js 1.24 kB
packages/pagination/dist/style.css 363 B
packages/popover/dist/index.es.js 3.07 kB
packages/popover/dist/index.js 3.58 kB
packages/popover/dist/style.css 632 B
packages/portal/dist/index.es.js 393 B
packages/portal/dist/index.js 453 B
packages/progress-bubbles/dist/index.es.js 1.77 kB
packages/progress-bubbles/dist/index.js 1.83 kB
packages/progress-bubbles/dist/style.css 969 B
packages/progress/dist/index.es.js 1.02 kB
packages/progress/dist/index.js 1.09 kB
packages/progress/dist/style.css 278 B
packages/select/dist/index.es.js 5.92 kB
packages/select/dist/index.js 6.01 kB
packages/select/dist/style.css 1.34 kB
packages/slider/dist/index.es.js 579 B
packages/slider/dist/index.js 645 B
packages/slider/dist/style.css 675 B
packages/snackbar/dist/index.es.js 1.18 kB
packages/snackbar/dist/index.js 1.73 kB
packages/snackbar/dist/style.css 581 B
packages/split-button/dist/index.es.js 887 B
packages/split-button/dist/index.js 959 B
packages/split-button/dist/style.css 496 B
packages/stack/dist/index.es.js 494 B
packages/stack/dist/index.js 565 B
packages/stack/dist/style.css 226 B
packages/tab-list/dist/index.es.js 737 B
packages/tab-list/dist/index.js 809 B
packages/tab-list/dist/style.css 460 B
packages/table/dist/index.es.js 1.02 kB
packages/table/dist/index.js 1.1 kB
packages/table/dist/style.css 912 B
packages/tag/dist/index.es.js 2.85 kB
packages/tag/dist/index.js 2.92 kB
packages/tag/dist/style.css 952 B
packages/toast/dist/index.es.js 979 B
packages/toast/dist/index.js 1.53 kB
packages/toast/dist/style.css 548 B
packages/toggle/dist/index.es.js 764 B
packages/toggle/dist/index.js 843 B
packages/toggle/dist/style.css 1.53 kB
packages/tokens/dist/index.css 1.86 kB
packages/tokens/dist/index.js 9.44 kB
packages/tokens/dist/media-queries.css 114 B
packages/tokens/dist/themes.css 1.49 kB
packages/tooltip/dist/index.es.js 515 B
packages/tooltip/dist/index.js 590 B
packages/tooltip/dist/style.css 370 B
packages/vars/dist/index.es.js 2.06 kB
packages/vars/dist/index.js 2.13 kB

compressed-size-action

@apucacao
Copy link
Contributor

@portpaw Looks like you and @Niznikr were on a similar wavelength.

@Niznikr Niznikr marked this pull request as ready for review October 31, 2023 19:47
@Niznikr Niznikr requested review from a team, apucacao, pheggeseth and kwatkins-ld October 31, 2023 19:47
@apucacao apucacao requested a review from jonmooring October 31, 2023 19:48
@jonmooring
Copy link
Contributor

I'd prefer to resolve differences between our two proposals before merging either (other proposal for reference). There's a lot here that I like (specifically the style generation from our tokens), but there are a few elements of my branch that could or maybe should be pulled over, too.

@Niznikr Can we set up some time early next week to discuss?

},
"dependencies": {
"@launchpad-ui/vars": "workspace:~",
"@radix-ui/react-slot": "^1.0.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we typically pin our dependencies?

'data-test-id'?: string;
};

const Box = ({ asChild, children, 'data-test-id': testId = 'box', ...props }: BoxProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a default test ID, or should we just omit this entirely if it's not provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps only set it if asChild is not present? We typically set a default test ID for all LP components.

// Build out utility classes that don't use CSS variables
display: ['block', 'flex', 'inline-block', 'inline-flex'],
},
shorthands: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apucacao expressed some concern with the shorthand properties and the legibility of them. Should we just omit them for now? (paddingY/paddingX/marginY/marginX might still make sense from a legibility perspective, though)

type FillKeys = FlattenObjectKeys<typeof fill>;
type TextKeys = FlattenObjectKeys<typeof text>;

const colors = flatten<typeof global, Record<GlobalKeys, string>>(global);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question about how we tokenize these. Do we want to use hyphen - delimiters rather than periods .? That would map more cleanly to how they're expressed in CSS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I slightly prefer the periods as it clears up the hierarchy/taxonomy of our tokens in cases where hyphens are used in some names (example).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, that makes sense to me!


const colorProperties = defineProperties({
conditions: {
lightMode: { selector: ':root &, [data-theme="default"] &' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small thing: Maybe this should just be default and dark, to match the names of the themes as they exist in other parts of the code?

},
});

const colorProperties = defineProperties({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be themedProperties and maybe include borderStyle as well? Not sure if that would be considered a themed value or a responsive value 🤔 I made it themed in my implementation, but I wasn't 100% confident in that decision.

borderColor: { ...colors, ...borders },
fill: { ...colors, ...fills },
},
shorthands: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here re: shorthand.

Comment on lines +65 to +67
flexDirection: true,
justifyContent: true,
alignItems: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing that's probably worth discussing: do we want flex properties to be part of a Flex component, rather than Box being overloaded?

Copy link
Contributor Author

@Niznikr Niznikr Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a Flex and Text component will likely be something we want as a follow-up to rein things in and offer precise dialing. Since Box is meant to be polymorphic by definition we should "allow it all" for quick prototyping and versatility. I imagine Box as a base class for other components/packages (Flex/Text) to extend/inherit from and where prop restriction would happen there.

Comment on lines +55 to +58
fontFamily: vars.font.family,
fontSize: vars.font.size,
fontWeight: vars.font.weight,
lineHeight: vars['line-height'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here: do we want to expose these properties on the Box component, or would we rather these concerns belong to a Text component?

@Niznikr Niznikr merged commit 47f7262 into main Nov 14, 2023
15 checks passed
@Niznikr Niznikr deleted the feat/box branch November 14, 2023 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants