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

Vanilla Extract rewrite #155

Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
efba2b7
Bump pnpm/action-setup from 2.2.2 to 2.4.0
dependabot[bot] Aug 1, 2023
d37dc4f
Update installation instructions to include peer dependencies (#133)
jakim929 Nov 17, 2023
c9528f5
Merge pull request #125 from ensdomains/dependabot/github_actions/pnp…
LeonmanRolls Feb 1, 2024
bf67706
feat: stylebox styling consistency tweaks
TateB Feb 14, 2024
c2b7566
update test
TateB Feb 14, 2024
540b4f8
Merge pull request #139 from ensdomains/feat/scrollbox-tweaks
TateB Feb 28, 2024
b0944f1
v0.6.45
github-actions[bot] Feb 28, 2024
099f751
fix: add types export
TateB Mar 13, 2024
d2120b4
Merge pull request #141 from ensdomains/fix/add-types-export
TateB Mar 13, 2024
68056fb
v0.6.46
github-actions[bot] Mar 13, 2024
c9da69f
allow passing ref to RecordItem
talentlessguy Mar 16, 2024
0fa494d
v0.6.46-beta
github-actions[bot] Mar 27, 2024
59522e4
allow passing custom postfix icon to record item
talentlessguy Mar 27, 2024
1adfcae
merge
talentlessguy Mar 27, 2024
c991871
Merge branch 'forward-ref-record-item' of https://github.com/ensdomai…
talentlessguy Mar 27, 2024
4aa7832
v0.6.46-beta.1
github-actions[bot] Mar 27, 2024
f397363
Merge pull request #142 from ensdomains/forward-ref-record-item
talentlessguy Mar 28, 2024
f051ecb
allow passing href to a dropdown item
talentlessguy Mar 29, 2024
6a3d740
Merge pull request #143 from ensdomains/dropdown-href
talentlessguy Mar 29, 2024
092c952
0.6.47
github-actions[bot] Mar 29, 2024
1f567a1
fix links for mobile dropdown, remove 'as'
talentlessguy Apr 10, 2024
12671ed
newline
talentlessguy Apr 10, 2024
10e5c6c
Merge pull request #144 from ensdomains/dropdown-mobile-fix
talentlessguy Apr 10, 2024
a3285ea
v0.6.48
github-actions[bot] Apr 10, 2024
5e36dbd
fix: small typo in dropdown
talentlessguy Apr 10, 2024
22ef37a
Merge pull request #145 from ensdomains/fix-small-typo-in-dropdown
talentlessguy Apr 10, 2024
fba0767
v0.6.49
github-actions[bot] Apr 10, 2024
4eb1e84
add Dialog.Content component and updated scrollbox
storywithoutend May 10, 2024
ea10184
fix scrollbox unit test
storywithoutend May 15, 2024
9e47b70
remove playroom build and links from docs
storywithoutend May 21, 2024
fb153a8
fix lint error
storywithoutend May 21, 2024
fab1329
remove playroom link from docs navigation
storywithoutend May 21, 2024
848291f
Remove playroom guides link
storywithoutend May 21, 2024
ebb0650
Merge pull request #151 from ensdomains/hotfix/disable-playroom
storywithoutend May 21, 2024
b4a7a6b
remove next.config rewrites
storywithoutend May 21, 2024
f9e768b
Merge pull request #152 from ensdomains/hotfix/disable-playroom
storywithoutend May 21, 2024
e9a7f48
remove playroom package
storywithoutend May 22, 2024
f0d7921
update preview index.html
storywithoutend May 22, 2024
c03217a
Update pnpm-lock.yaml
storywithoutend May 22, 2024
bc843a3
fix lint errors
storywithoutend May 22, 2024
f3e536d
Merge pull request #153 from ensdomains/hotfix/disable-playroom
storywithoutend May 22, 2024
16e673e
Merge pull request #146 from ensdomains/add-scrollbox-divider-always-…
storywithoutend May 23, 2024
38f856c
v0.6.50
github-actions[bot] May 23, 2024
51629b2
resolve conflicts
storywithoutend Jul 30, 2024
89c9ad8
bump actions and pnpm
talentlessguy Aug 7, 2024
5222a0e
fix lint problems
talentlessguy Aug 7, 2024
5c8a2a1
remove jest and styled-components related deps
talentlessguy Aug 7, 2024
430178b
rewrite some styled components to ve
talentlessguy Aug 7, 2024
c332377
rewrite DialogContent
talentlessguy Aug 7, 2024
45375fc
remove eslint 7
talentlessguy Aug 7, 2024
7420cab
wip: use eslint + stylelint v9 flat config
talentlessguy Aug 7, 2024
a6813a0
wip centralized config
talentlessguy Aug 7, 2024
b85fcc8
docs eslint config
talentlessguy Aug 7, 2024
57f6de7
wip reconfiguring eslint & ts
talentlessguy Aug 7, 2024
4900033
make docs lint pass
talentlessguy Aug 7, 2024
a61cac8
run eslint on components
talentlessguy Aug 7, 2024
518a42e
wip fix components lint
talentlessguy Aug 7, 2024
20f200d
fix components lint errors
talentlessguy Aug 7, 2024
ebf61d6
fix some build errors and start vitest setup
talentlessguy Aug 8, 2024
574c5a0
make vite build not fail
talentlessguy Aug 8, 2024
694e34c
fix vite build (not types yet)
talentlessguy Aug 9, 2024
9a00af1
fix another type error
talentlessguy Aug 9, 2024
f638060
wip moving icons to jsx
talentlessguy Aug 9, 2024
d048483
wip icons moving
talentlessguy Aug 9, 2024
7332682
95.2% of tests pass
talentlessguy Aug 11, 2024
dc4d3ca
make build work, remove unused plugins, fix stylelint
talentlessguy Aug 11, 2024
57b6380
undo attempts of using a separate tsc step
talentlessguy Aug 11, 2024
9bde836
fix css emit and wip docs build
talentlessguy Aug 11, 2024
e393560
move the rest of icons to the icons.txt file and fix docs css
talentlessguy Aug 11, 2024
b002544
fix website build
talentlessguy Aug 11, 2024
51805a5
remove icons from sidebar for now
talentlessguy Aug 11, 2024
d20506a
fix codepreview font
talentlessguy Aug 11, 2024
1cca7e6
rename
talentlessguy Aug 11, 2024
c4acac0
fix some stuff in the docs
talentlessguy Aug 11, 2024
c1d0355
fix themetoggle icon size
talentlessguy Aug 11, 2024
8c35b9e
remove unused deps
talentlessguy Aug 11, 2024
1bf75d5
fix icon fill
talentlessguy Aug 11, 2024
9f63d75
prefix identifiers with `thorin-` and fix Select icon prefixes
talentlessguy Aug 12, 2024
19e710f
fix mono font
talentlessguy Aug 12, 2024
1ae5697
fix textarea and prefix css vars
talentlessguy Aug 12, 2024
5e91184
fix dialog colors
talentlessguy Aug 12, 2024
9702629
fix tooltip colors
talentlessguy Aug 12, 2024
c06cc80
ignore 3 failing tests
talentlessguy Aug 15, 2024
f2208e4
make docs build
talentlessguy Aug 15, 2024
714dac0
fix paths
talentlessguy Aug 15, 2024
0b68772
coverage
talentlessguy Aug 15, 2024
f9db9a9
fix node version
talentlessguy Aug 15, 2024
93d3295
fix svg properties
talentlessguy Aug 16, 2024
95693b7
fix doc site build and remove SC related stuff
talentlessguy Aug 16, 2024
19fb042
await `waitFor` and skip failing tests for now
talentlessguy Aug 21, 2024
9c799f0
unskip failing tests because it doesn't work irl either
talentlessguy Aug 21, 2024
9adc2cb
remove lodash from deps
talentlessguy Aug 24, 2024
0795d32
add build:watch script
talentlessguy Aug 24, 2024
6ea9dc2
fix toast
storywithoutend Aug 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2.2.2
- uses: pnpm/action-setup@v2.4.0
with:
version: 7.8.0
talentlessguy marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -39,7 +39,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2.2.2
- uses: pnpm/action-setup@v2.4.0
with:
version: 7.8.0

Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: pnpm/action-setup@v2.2.2
- uses: pnpm/action-setup@v2.4.0
with:
version: 7.8.0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
ref: ${{ github.event.release.target_commitish }}

- uses: pnpm/action-setup@v2.2.2
- uses: pnpm/action-setup@v2.4.0
with:
version: 7.8.0

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ yarn-error.log*

docs/.next/
docs/out/
docs/public/playroom/
# docs/public/playroom/
docs/src/playroom/snippets

components/dist/
Expand Down
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": false,
"source.organizeImports": false
"source.fixAll.eslint": "explicit",
"source.fixAll.stylelint": "never",
"source.organizeImports": "never"
},
"editor.formatOnSave": true,
"eslint.options": {
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ A design system for ENS built with React and styled-components.
To install this package using npm:

```bash
npm install @ensdomains/thorin
npm install @ensdomains/thorin styled-components [email protected]

```

To install this package using yarn:

```bash
yarn add @ensdomains/thorin
yarn add @ensdomains/thorin styled-components [email protected]
```

Checkout the project's [playroom](https://thorin.ens.domains/playroom) to preview the components in a live online environment.
Expand Down
5 changes: 3 additions & 2 deletions components/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "@ensdomains/thorin",
"version": "0.6.45",
"version": "0.6.50",
"description": "A web3 native design system",
"main": "./dist/index.cjs.js",
"module": "./dist/index.es.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.cjs.js"
"require": "./dist/index.cjs.js",
"types": "./dist/types/index.d.ts"
},
"./styles.css": {
"import": "./dist/style.css",
Expand Down
80 changes: 47 additions & 33 deletions components/src/components/atoms/RecordItem/RecordItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ type BaseProps = {
children: string
onClick?: () => void
as?: 'button' | 'a'
postfixIcon?: React.FunctionComponent<
React.SVGProps<SVGSVGElement> & { title?: string }
>
}

type NativeElementProps = Omit<
Expand Down Expand Up @@ -147,37 +150,45 @@ const TrailingSVGBox = ({
/>
)

export const RecordItem = ({
as: asProp = 'button',
link,
size = 'small',
inline = false,
icon,
keyLabel,
keySublabel,
value,
children,
...props
}: Props) => {
const { copy, copied } = useCopied()

const generatedProps =
asProp === 'a'
? ({
href: link,
rel: 'nofollow noreferrer',
target: '_blank',
...props,
} as NativeElementProps & NativeAnchorProps)
: ({
onClick: () => {
copy(value)
},
...props,
} as NativeElementProps & NativeButtonProps)

const hasPrefix = !!icon || !!keyLabel
const hasLabels = !!keyLabel || !!keySublabel
export const RecordItem = React.forwardRef<
HTMLAnchorElement | HTMLButtonElement,
Props
>(
(
{
as: asProp = 'button',
link,
size = 'small',
inline = false,
postfixIcon,
icon,
keyLabel,
keySublabel,
value,
children,
...props
},
ref,
) => {
const { copy, copied } = useCopied()

const generatedProps =
asProp === 'a'
? ({
href: link,
rel: 'nofollow noreferrer',
target: '_blank',
...props,
} as NativeElementProps & NativeAnchorProps)
: ({
onClick: () => {
copy(value)
},
...props,
} as NativeElementProps & NativeButtonProps)

const hasPrefix = !!icon || !!keyLabel
const hasLabels = !!keyLabel || !!keySublabel

const KeyLabel =
typeof keyLabel === 'string' ? (
Expand Down Expand Up @@ -208,7 +219,9 @@ export const RecordItem = ({
) : (
keySublabel
)
const PostfixProps = link
const PostfixProps = postfixIcon
? { as: postfixIcon }
: link
? { $rotate: true, as: UpArrowSVG }
: copied
? { as: CheckSVG }
Expand Down Expand Up @@ -238,6 +251,7 @@ export const RecordItem = ({
<TrailingSVGBox {...(PostfixProps as any)} />
</ContainerBox>
)
}
})


RecordItem.displayName = 'RecordItem'
100 changes: 61 additions & 39 deletions components/src/components/atoms/ScrollBox/ScrollBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,69 @@ import * as React from 'react'

import * as styles from './styles.css'
import { Box, BoxProps } from '../Box/Box'
import { commonVars } from '@/src/css/theme.css'
import { Space } from '@/src/tokens'

const ScrollBoxBox = React.forwardRef<HTMLElement, BoxProps>((props, ref) => (
<Box
overflowX="auto"
overflowY="auto"
position="relative"
ref={ref}
transitionDuration="$150"
transitionProperty="all"
transitionTimingFunction="$inOut"
classNames={styles.scrollBox}
{...props}
/>
))

const DividerBox = ({
show,
position,
horizontalPadding,
}: {
show: boolean
position: 'top' | 'bottom'
}) => (
horizontalPadding?: Space
}) => {
return (
<Box
backgroundColor="$greyLight"
bottom={position === 'bottom' ? '$0' : 'unset'}
style={horizontalPadding ? { width: `calc(100% - 2 * ${commonVars.space[horizontalPadding]})`} : {}}
backgroundColor={show ? '$border' : 'transparent'}
bottom={position === 'bottom' ? '-$px' : 'unset'}
data-testid={`scrollbox-${position}-divider`}
display="block"
height="$px"
left="$0"
opacity={show ? '1' : '0'}
position="sticky"
left={horizontalPadding ? commonVars.space[horizontalPadding] :"$0"}
position="absolute"
top={position === 'top' ? '$0' : 'unset'}
transitionDuration="$150"
transitionProperty="opacity"
transitionProperty="background-color"
transitionTimingFunction="$inOut"
width="$full"
zIndex="100"
/>
)
/>)}

type Props = {
/** If true, the dividers will be hidden */
hideDividers?: boolean | { top?: boolean; bottom?: boolean }
/** If true, the dividers will always be shown */
alwaysShowDividers?: boolean | { top?: boolean; bottom?: boolean }
/** The number of pixels below the top of the content where events such as showing/hiding dividers and onReachedTop will be executed */
topTriggerPx?: number
/** The number of pixels above the bottom of the content where events such as showing/hiding dividers and onReachedTop will be executed */
bottomTriggerPx?: number
/** A callback function that is fired when the content reaches topTriggerPx */
onReachedTop?: () => void
/** A callback function that is fired when the content reaches bottomTriggerPx */
onReachedBottom?: () => void
/** The amount of horizontal padding to apply to the scrollbox. This will decrease the content area as well as the width of the overflow indicator dividers*/
horizontalPadding?: Space
} & BoxProps

export const ScrollBox = ({
hideDividers = false,
alwaysShowDividers = false,
topTriggerPx = 16,
bottomTriggerPx = 16,
onReachedTop,
onReachedBottom,
horizontalPadding,
children,
...props
}: Props) => {
Expand All @@ -66,14 +76,22 @@ export const ScrollBox = ({
typeof hideDividers === 'boolean' ? hideDividers : !!hideDividers?.top
const hideBottom =
typeof hideDividers === 'boolean' ? hideDividers : !!hideDividers?.bottom
const alwaysShowTop =
typeof alwaysShowDividers === 'boolean'
? alwaysShowDividers
: !!alwaysShowDividers?.top
const alwaysShowBottom =
typeof alwaysShowDividers === 'boolean'
? alwaysShowDividers
: !!alwaysShowDividers?.bottom

const funcRef = React.useRef<{
onReachedTop?: () => void
onReachedBottom?: () => void
}>({ onReachedTop, onReachedBottom })

const [showTop, setShowTop] = React.useState(false)
const [showBottom, setShowBottom] = React.useState(false)
const [showTop, setShowTop] = React.useState(alwaysShowTop)
const [showBottom, setShowBottom] = React.useState(alwaysShowBottom)

const handleIntersect: IntersectionObserverCallback = (entries) => {
const intersectingTop: [boolean, number] = [false, -1]
Expand All @@ -87,9 +105,13 @@ export const ScrollBox = ({
iref[1] = entry.time
}
}
intersectingTop[1] !== -1 && !hideTop && setShowTop(!intersectingTop[0])
intersectingTop[1] !== -1 &&
!hideTop &&
!alwaysShowTop &&
setShowTop(!intersectingTop[0])
intersectingBottom[1] !== -1 &&
!hideBottom &&
!alwaysShowBottom &&
setShowBottom(!intersectingBottom[0])
intersectingTop[0] && funcRef.current.onReachedTop?.()
intersectingBottom[0] && funcRef.current.onReachedBottom?.()
Expand Down Expand Up @@ -120,28 +142,28 @@ export const ScrollBox = ({
}, [onReachedTop, onReachedBottom])

return (
<ScrollBoxBox
// $showBottom={showBottom}
// $showTop={showTop}
className={styles.scrollBox}
ref={ref}
<Box
position="relative"
border="solid $px transparent"
width="$full"
height="$full"
borderLeftWidth="$0"
borderRightWidth="$0"
{...props}
>
<DividerBox position="top" show={showTop} />
<Box
data-testid="scrollbox-top-intersect"
display="block"
height="$0"
ref={topRef}
/>
{children}
<Box
data-testid="scrollbox-bottom-intersect"
display="block"
height="$0"
ref={bottomRef}
/>
<DividerBox position="bottom" show={showBottom} />
</ScrollBoxBox>
<ScrollBoxBox style={horizontalPadding ? {
padding: `0 ${commonVars.space[horizontalPadding]}`,
} : {}}>
<Box data-testid="scrollbox-top-intersect" ref={topRef}
display="block" height="$0"
/>
{children}
<Box data-testid="scrollbox-bottom-intersect" ref={bottomRef}
display="block" height="$0"
/>
</ScrollBoxBox>
<DividerBox data-testid="scrollbox-top-line" show={showTop} position='top' horizontalPadding={horizontalPadding}/>
<DividerBox data-testid="scrollbox-bottom-line" show={showBottom} position='bottom' horizontalPadding={horizontalPadding}/>
</Box>
)
}
Loading
Loading