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

[FX-4554] Export useFieldsLayoutContext hook #4033

Merged
merged 4 commits into from
Nov 30, 2023

Conversation

sashuk
Copy link
Contributor

@sashuk sashuk commented Nov 29, 2023

FX-4554

Description

This pull requests exports useFieldsLayoutContext() hook, so consumers can build their own form extensions to match the layout.

How to test

  • Temploy
  • Test the code below in Storybook, the buttons form footer should be adaptable
import React from 'react'
import { Container } from '@toptal/picasso'
import { useFieldsLayoutContext } from '@toptal/picasso'
import {
  FormNonCompound as Form,
  Input,
  SubmitButton,
  Switch,
} from '@toptal/picasso-forms'

const initialValues = {}

const Buttons = () => {
  const { layout } = useFieldsLayoutContext()
  return (
    <Container style={layout === 'horizontal' ? {
      display: 'grid',
      gridTemplateRows: 'auto auto',
      gridTemplateAreas: `"label input" "hint error"`,
      gridTemplateColumns: '272px 1fr',
      paddingTop: '1rem',
      gap: '0 32px'
    } : {}}
  >
    <div>AAAA</div>
    <div><SubmitButton>Submit</SubmitButton></div>
  </Container>
  )
}

const Example = () => {
  return (
    <Form
      autoComplete='off'
      onSubmit={values => window.alert(JSON.stringify(values, undefined, 2))}
      initialValues={initialValues}
      layout='horizontal'
    >
      <Input
        enableReset
        onResetClick={(set: (value: string) => void) => {
          set('')
        }}
        required
        name='default-firstName'
        label='First name'
        placeholder='e.g. Bruce'
      />
      <Switch
        name='default-publicProfile'
        label='Public Profile'
        width='auto'
      />
        <Buttons/>
    </Form>
  )
}

export default Example

Kapture.2023-11-29.at.13.29.02.mp4

Screenshots

Tested locally on sample app

Kapture.2023-11-29.at.13.17.15.mp4

Development checks

All development checks should be done and set checked to pass the
GitHub Bot: TODOLess action

PR commands

List of available commands:

  • @toptal-bot run package:alpha-release - Release alpha version
  • @toptal-anvil ping reviewers - Ping FX team for review
PR Review Guidelines

When to approve? ✅

You are OK with merging this PR and

  1. You have no extra requests.
  2. You have optional requests.
    1. Add nit: to your comment. (ex. nit: I'd rename this variable from makeCircle to getCircle)

When to request changes? ❌

You are not OK with merging this PR because

  1. Something is broken after the changes.
  2. Acceptance criteria is not reached.
  3. Code is dirty.

When to comment (neither ✅ nor ❌)

You want your comments to be addressed before merging this PR in cases like:

  1. There are leftovers like unnecessary logs, comments, etc.
  2. You have an opinionated comment regarding the code that requires a discussion.
  3. You have questions.

How to handle the comments?

  1. An owner of a comment is the only one who can resolve it.
  2. An owner of a comment must resolve it when it's addressed.
  3. A PR owner must reply with ✅ when a comment is addressed.

@sashuk sashuk self-assigned this Nov 29, 2023
Copy link

changeset-bot bot commented Nov 29, 2023

🦋 Changeset detected

Latest commit: 9bc037e

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

This PR includes changesets to release 2 packages
Name Type
@toptal/picasso-forms Minor
@toptal/picasso Minor

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

@sashuk
Copy link
Contributor Author

sashuk commented Nov 29, 2023

@toptal-bot run package:alpha-release

@toptal-devbot
Copy link
Collaborator

Your alpha package is ready 🎉
yarn add @topkit/analytics-charts@52.0.1-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.93+28c3ba462
yarn add @toptal/picasso@41.4.2-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.1+28c3ba462
yarn add @toptal/picasso-charts@55.1.1-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.55+28c3ba462
yarn add @toptal/picasso-codemod@5.6.4-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.44+28c3ba462
yarn add @toptal/picasso-forms@65.1.2-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.1+28c3ba462
yarn add @toptal/picasso-pictograms@2.0.1-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.114+28c3ba462
yarn add @toptal/picasso-provider@3.4.2-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.105+28c3ba462
yarn add @toptal/picasso-query-builder@1.1.3-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.25+28c3ba462
yarn add @toptal/picasso-rich-text-editor@9.0.2-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.64+28c3ba462
yarn add @toptal/picasso-shared@13.0.1-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.114+28c3ba462
yarn add @toptal/picasso-tailwind@1.0.1-alpha-FX-NULL-export-useFieldsLayoutContext-28c3ba462.18+28c3ba462

@sashuk sashuk changed the title Export useFieldsLayoutContext hook [FX-4554] Export useFieldsLayoutContext hook Nov 29, 2023
@sashuk sashuk force-pushed the FX-NULL-export-useFieldsLayoutContext branch from 5d8b97a to e2bba0a Compare November 29, 2023 12:33
@toptal toptal deleted a comment from toptal-devbot Nov 29, 2023
@sashuk sashuk marked this pull request as ready for review November 29, 2023 12:39
@sashuk sashuk requested a review from a team November 29, 2023 12:40
@sashuk
Copy link
Contributor Author

sashuk commented Nov 29, 2023

@toptal-anvil ping reviewers

@sashuk sashuk requested a review from a team November 29, 2023 12:47
@sashuk
Copy link
Contributor Author

sashuk commented Nov 30, 2023

@toptal-anvil ping reviewers

@sashuk sashuk force-pushed the FX-NULL-export-useFieldsLayoutContext branch from fd188ea to 9bc037e Compare November 30, 2023 12:09
@sashuk sashuk merged commit 090c794 into master Nov 30, 2023
13 checks passed
@sashuk sashuk deleted the FX-NULL-export-useFieldsLayoutContext branch November 30, 2023 13:49
@toptal-build toptal-build mentioned this pull request Nov 30, 2023
1 task
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.

4 participants