Skip to content

Commit

Permalink
[FX-5545] Migrate Note to TailwindCSS (#4479)
Browse files Browse the repository at this point in the history
* Migrate Notes to tailwind

* Migrate NoteTitle to tailwind

* Add changeset

* Update snapshots

* Fix small incosistencies

* Update package changeset

* Reformat classnames
  • Loading branch information
Augusto Moura authored Aug 17, 2024
1 parent 03e25d8 commit 4a32b80
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 58 deletions.
6 changes: 6 additions & 0 deletions .changeset/little-papayas-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@toptal/picasso-note': major
'@toptal/picasso': patch
---

- migrate Note to TailwindCSS, the packages `@toptal/picasso-tailwind-merge` now need to be provided from the host project, and tailwind needs to be configured for compiling `@toptal/picasso-note` using `@toptal/picasso-tailwind` configuration
2 changes: 2 additions & 0 deletions packages/base/Note/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@toptal/picasso-container": "2.0.0",
"@toptal/picasso-typography": "3.0.0",
"@toptal/picasso-tailwind-merge": "1.2.0",
"classnames": "^2.5.1"
},
"sideEffects": [
Expand All @@ -33,6 +34,7 @@
"peerDependencies": {
"@material-ui/core": "4.12.4",
"@toptal/picasso-tailwind": ">=2.7",
"@toptal/picasso-tailwind-merge": "^1.0.1",
"react": ">=16.12.0 < 19.0.0"
},
"exports": {
Expand Down
28 changes: 18 additions & 10 deletions packages/base/Note/src/Note/Note.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
import React, { forwardRef } from 'react'
import type { Theme } from '@material-ui/core/styles'
import { makeStyles } from '@material-ui/core/styles'
import type { BaseProps } from '@toptal/picasso-shared'
import cx from 'classnames'

import styles from './styles'
import { twMerge } from '@toptal/picasso-tailwind-merge'

export interface Props extends BaseProps {
children: React.ReactNode
}

const useStyles = makeStyles<Theme>(styles)

export const Note = forwardRef<HTMLDivElement, Props>(function Note(
{ children, className, ...rest },
ref
) {
const classes = useStyles()

return (
<div ref={ref} className={cx(classes.root, className)} {...rest}>
<div
ref={ref}
className={twMerge(
`rounded-md border border-solid border-gray-200 py-6 pr-6 pl-[28px] relative overflow-hidden bg-white
before:content-['']
before:bg-yellow-500
before:block
before:h-full
before:absolute
before:top-0
before:left-0
before:w-[4px]`,
className
)}
{...rest}
>
{children}
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions packages/base/Note/src/Note/__snapshots__/test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ exports[`Note renders 1`] = `
class="Picasso-root"
>
<div
class="makeStyles-root"
class="rounded-md border border-solid border-gray py-6 pr-6 pl-[28px] relative overflow-hidden bg-white before:content-[''] before:bg-yellow before:block before:h-full before:absolute before:top-0 before:left-0 before:w-[4px]"
>
<div
class="makeStyles-root"
class="mb-1"
>
<h4
class="m-0 text-md text-black font-semibold"
Expand Down
28 changes: 0 additions & 28 deletions packages/base/Note/src/Note/styles.ts

This file was deleted.

12 changes: 2 additions & 10 deletions packages/base/Note/src/NoteTitle/NoteTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
import React, { forwardRef } from 'react'
import type { Theme } from '@material-ui/core/styles'
import { makeStyles } from '@material-ui/core/styles'
import type { BaseProps } from '@toptal/picasso-shared'
import cx from 'classnames'
import { Typography } from '@toptal/picasso-typography'

import styles from './styles'
import { twMerge } from '@toptal/picasso-tailwind-merge'

export interface Props extends BaseProps {
children: React.ReactNode
}

const useStyles = makeStyles<Theme>(styles)

export const NoteTitle = forwardRef<HTMLDivElement, Props>(function NoteTitle(
{ children, className, ...rest },
ref
) {
const classes = useStyles()

return (
<div ref={ref} className={cx(classes.root, className)} {...rest}>
<div ref={ref} className={twMerge('mb-1', className)} {...rest}>
<Typography variant='heading' size='small'>
{children}
</Typography>
Expand Down
8 changes: 0 additions & 8 deletions packages/base/Note/src/NoteTitle/styles.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/base/Note/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"include": ["src"],
"references": [
{ "path": "../../picasso-tailwind" },
{ "path": "../../picasso-tailwind-merge" },
{ "path": "../Container" },
{ "path": "../Typography" }
]
Expand Down

0 comments on commit 4a32b80

Please sign in to comment.