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

Box: Add design guidelines and update documentation #1358

Merged
merged 25 commits into from Feb 5, 2021

Conversation

ayeshakmaz
Copy link
Contributor

@ayeshakmaz ayeshakmaz commented Jan 29, 2021

Update Box docs to new style

Test Plan

Lots of manual testing and feedback gathering

@netlify
Copy link

netlify bot commented Jan 29, 2021

Deploy preview for gestalt ready!

Built with commit 60e3d7e

https://deploy-preview-1358--gestalt.netlify.app

@ayeshakmaz ayeshakmaz marked this pull request as ready for review January 30, 2021 00:59
@ayeshakmaz ayeshakmaz requested a review from a team as a code owner January 30, 2021 00:59
docs/src/Flex.doc.js Outdated Show resolved Hide resolved
Copy link
Contributor

@dangerismycat dangerismycat left a comment

Choose a reason for hiding this comment

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

I can't believe you started with Box 😂 so much work! Nice job!

The layout is a bit confusing…I'm having a hard time telling which header/content goes with which example. I think we need to space things out a bit more.

We're also currently in a "worst of both worlds" with the props table positioning. It's not immediately visible at the top, but it's also not at the bottom, it's…somewhere in the middle. That is going to frustrate a lot of people.

Not sure if this is already planned for future work, but I think we can compress the combination examples a bit more. I get the need for whitespace, but these are displayed pretty inefficiently right now. (But the text doesn't overlap! 😍 )

docs/src/BOILERPLATE.doc.js Outdated Show resolved Hide resolved
docs/src/BOILERPLATE.doc.js Outdated Show resolved Hide resolved
docs/src/BOILERPLATE.doc.js Outdated Show resolved Hide resolved
docs/src/BOILERPLATE.doc.js Outdated Show resolved Hide resolved
docs/src/BOILERPLATE.doc.js Outdated Show resolved Hide resolved
docs/src/Flex.doc.js Outdated Show resolved Hide resolved
docs/src/components/CombinationNew.js Outdated Show resolved Hide resolved
docs/src/components/CombinationNew.js Outdated Show resolved Hide resolved
docs/src/components/MainSection.js Show resolved Hide resolved
docs/src/components/MainSectionCard.js Outdated Show resolved Hide resolved
'darkWash',
]}
>
{(props) => <Box width={60} height={60} rounding="circle" {...props} />}
Copy link
Contributor

Choose a reason for hiding this comment

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

can we avoid spreading props?

We don't allow it (Eslint rule) in Pinboard as a best practice. Codemods can't read them.

docs/src/Box.doc.js Outdated Show resolved Hide resolved
docs/src/Box.doc.js Outdated Show resolved Hide resolved
@AlbertCarreras
Copy link
Contributor

image

description={`
The [media object](http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/) is a common pattern for displaying data. What's interesting about this example is the use of \`flex\` to align the items. If you try changing the size of the \`Avatar\` or the number of lines of \`Text\`, both will stay aligned because they are center aligned.

In the double-sided example we use \`flex="grow"\` to mark a flex child as something that can expand. Try removing the \`grow\` property and see what happens.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a writer question... what's the tone of these texts?
Try removing the \grow` property and see what happens.` We should discuss the tone of the Docs, is it a friendly voice that guide's you in the discovery of the Docs or just a standard Doc voice that simply describes?

I thnk it's important to get to the voice, maybe in a second round, but the sooner the less we'll have to change work already done.

docs/src/Box.doc.js Outdated Show resolved Hide resolved
<Heading size="sm">{title}</Heading>
<IconButton
dangerouslySetSvgPath={{
__path:
Copy link
Contributor

Choose a reason for hiding this comment

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

are we reusing this link icon somewhere else? could we create a const and export if so? Maybe it's just used here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will address this separately

Copy link
Contributor

@AlbertCarreras AlbertCarreras left a comment

Choose a reason for hiding this comment

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

There are a few nits you can address before merging, then there are other major comments re Box content & related or even some design issues that I think are out of scope for this PR.

@AlbertCarreras
Copy link
Contributor

AlbertCarreras commented Feb 3, 2021

New comments:

  • Props table: props not properly linked: alignItems, column, dangerouslySetInlineStyle (maybe linked to best practices? dangerlusly vs div? ), justifyContent, margin (to auto margin?), opacity
    -for those Flex-related props, should we link them to 'Related'?

General observations:

  • fit doesn't have any description not example.
  • role doesn't have any description not example
  • userSelect could have an example, it's pretty abstract as per the description
  • we have responsive 1. columns, 2. margin/marginStart/marginEnd/marginTop/marginBottom, 3. padding/paddingX/paddingY. However, there's only one variant for responsive padding? Should we document all cases?

docs/src/Box.doc.js Outdated Show resolved Hide resolved

const cards: Array<Node> = [];
const card = (c) => cards.push(c);

card(
<PageHeader
name="Box"
description={`In the darkest night, Box will rise to bring the light. The Lloyd has spoken.
&mdash; Anon _(Winning Box Haiku, 2017)_`}
description="Box is a component primitive that can be used to build the foundation of pretty much any other component. Using Box allows users to focus on the content, while keeping the pixel details, like spacing, borders, or colors, automatically consistent with the rest of Gestalt."
Copy link
Contributor

Choose a reason for hiding this comment

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

The second sentence is a little awkward (and uses the Oxford comma, which hurts my soul to remove, but I do what Kelly tells me to do 😅). Perhaps something like
"It keeps details like spacing, borders and colors consistent with the rest of Gestalt, while allowing the developer to focus on the content."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Love it!

cardSize="md"
type="do"
description={`
Use Box as a building block when creating other components or layouts that do not rely on Flexbox. The included properties should cover any variations needed to create a diverse range of options.
Copy link
Contributor

Choose a reason for hiding this comment

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

<MainSection.Card
cardSize="md"
type="don't"
description={`Avoid using arbitrary \`<div>\` elements. Instead, when building a component, prioritize using Box. If you need to set a custom style, you can do so using the \`dangerouslySetInlineStyle\` prop. However, this should be avoided whenever possible by utilizing the other props provided in Box.`}
Copy link
Contributor

Choose a reason for hiding this comment

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

You may also want to mention / link to our lint rule for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call

<MainSection.Card
cardSize="lg"
defaultCode={`
function BoxFlyoutExample() {
Copy link
Contributor

Choose a reason for hiding this comment

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

it would still be nice to be able to close the Flyout 😅

function Example() {
const HEADER_ZINDEX = new FixedZIndex(100);
const zIndex = new CompositeZIndex([HEADER_ZINDEX]);
return <Box color="blue" width={60} height={60} zIndex={zIndex} />
return <Box color="midnight" width={60} height={60} zIndex={zIndex} />
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would be better demonstrated with two (or more) Boxes with various z-indices? A single Box doesn't convey the layering aspect

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :D


card(
<MainSection
name="Related"
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree in general but think it's fine to break that rule for Box, since it's so foundational. I don't think it's really clear when a user would want Card, Column, or Letterbox

(this can def be addressed in a future PR)

docs/src/Flex.doc.js Show resolved Hide resolved
</Box>
)}

<Box width="80%" marginTop={-2} marginBottom={6}>
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 want to render this empty Box if there is no description? I would think "no" in general

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We actually do in this case to account for a funky spacing thing

Copy link
Contributor

Choose a reason for hiding this comment

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

That doesn't sound like the right solution. Can that be solved by using flex properties on the parent/siblings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrapped it in a Box instead since Flex doesn't have margin

@ayeshakmaz ayeshakmaz added the patch release Patch release label Feb 5, 2021
@ayeshakmaz ayeshakmaz merged commit 899cb22 into pinterest:master Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch release Patch release
Projects
None yet
3 participants