Skip to content

Commit 3f6f72c

Browse files
authored
Tailwind upgrade (#856)
* chore(deps): bump @sajari-ui/core, prism-react-renderer, react-dom, tailwindcss to 2.x, Tailwind UI, twin.macro, and postcss-import * fix: add native focus interactions for button and combobox components * fix: add native focus interactions for link, select and tab components * fix: add native focus interactions for range input and swatch components * fix: remove unused ring style hooks * update snapshots * fix: documentation typos * chore: add changeset * chore(deps): bump react peer dependency in utils
1 parent c16e30f commit 3f6f72c

File tree

48 files changed

+1115
-843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1115
-843
lines changed

.changeset/afraid-boxes-invent.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'sajari-sdk-docs': major
3+
'@sajari/react-components': major
4+
'@sajari/react-hooks': major
5+
'@sajari/react-search-ui': major
6+
'@sajari/server': major
7+
'@sajari/react-sdk-utils': major
8+
---
9+
10+
Major version bump of Tailwind. Require React 17 peer dependency. Remove useFocusRingStyles and useRingStyles hooks.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
## Introduction
66

7-
The Sajari React SDK is a library of React Hooks and Components to help build fast and powerful search interfaces.
7+
The Search.io React SDK is a library of React Hooks and Components to help build fast and powerful search interfaces.
88

9-
React provides a simple and elegant way to structure user interfaces. Aside from providing generic UI components, the Sajari React SDK also provides a way to seamlessly integrate the Sajari Search platform into any web-based app through the use of easily composable Components.
9+
React provides a simple and elegant way to structure user interfaces. Aside from providing generic UI components, the Search.io React SDK also provides a way to seamlessly integrate the Search.io Search platform into any web-based app through the use of easily composable Components.
1010

1111
There are three main packages allowing you to pick and choose the right solution for your application:
1212

13-
The Sajari React SDK is broken into 4 separate packages:
13+
The Search.io React SDK is broken into 4 separate packages:
1414

1515
### @sajari/react-components
1616

@@ -32,7 +32,7 @@ Easy to use search components to quickly build a beautiful search interface. If
3232

3333
### @sajari/server
3434

35-
Helpers for server-side rendering your React application using Sajari search.
35+
Helpers for server-side rendering your React application using Search.io search.
3636

3737
## Documentation
3838

docs/components/SearchBar/SearchModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const SearchModal = ({ open, onClose }: Props) => {
109109
onKeyDown={onKeyDown}
110110
placeholder="Search the docs"
111111
borderWidth="border-0"
112-
boxShadow="focus:shadow-none"
112+
ringWidth="focus:ring-0"
113113
padding="px-0"
114114
/>
115115
</Flex>

docs/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@mdx-js/mdx": "^1.6.22",
1313
"@mdx-js/react": "^1.6.22",
1414
"@next/mdx": "^12.0.9",
15-
"@sajari-ui/core": "^0.20.0",
15+
"@sajari-ui/core": "^3.0.2",
1616
"@sajari/react-components": "^1.15.0",
1717
"@sajari/react-hooks": "^3.15.0",
1818
"@sajari/react-search-ui": "^4.19.0",
@@ -21,21 +21,21 @@
2121
"lorem-ipsum": "^2.0.3",
2222
"next": "^12.0.9",
2323
"next-seo": "^5.0.0",
24-
"prism-react-renderer": "^1.1.1",
24+
"prism-react-renderer": "^1.3.5",
2525
"react": "^17.0.1",
26-
"react-dom": "^17.0.1",
26+
"react-dom": "^17.0.2",
2727
"react-live": "^2.2.3",
2828
"remark-autolink-headings": "6.0.1",
2929
"remark-emoji": "2.1.0",
3030
"remark-images": "2.0.0",
3131
"remark-slug": "6.0.0",
3232
"remark-unwrap-images": "2.0.0",
33-
"tailwindcss": "^1.9.6"
33+
"tailwindcss": "^2.2.19"
3434
},
3535
"devDependencies": {
3636
"@next/eslint-plugin-next": "^12.0.9",
3737
"eslint-config-prettier": "^8.3.0",
3838
"postcss-clean": "^1.2.2",
39-
"postcss-import": "^14.0.2"
39+
"postcss-import": "^14.1.0"
4040
}
4141
}

docs/pages/_app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const Layout = (props: FlexProps) => {
3535
{...rest}
3636
>
3737
<Flex alignItems="items-center">
38-
<Logomark useNewLogomark size="sm" margin="mr-3" />
38+
<Logomark size="sm" margin="mr-3" />
3939
<Heading as="h3" size="md">
4040
React SDK
4141
</Heading>

docs/pages/components/radio.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function RadioExample() {
6262
### Custom Radio Buttons
6363

6464
In some cases, you might need to create components that work like radios but
65-
don't look like radios. Chakra exports a `RadioGroup` to help with this
65+
don't look like radios. The Search.io React SDK exports a `RadioGroup` to help with this
6666
scenario. Here's what you need to do:
6767

6868
1. Create a component that accepts the `checked` and `disabled` props. Be

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"test:ci": "turbo run test:ci --filter=!sajari-sdk-docs -- --passWithNoTests",
88
"build": "turbo run build --filter=!sajari-sdk-docs",
99
"prepublish": "turbo run prepublish",
10-
"docs": "turbo -filter=sajari-sdk-docs dev",
11-
"build:docs": "turbo run build -filter=sajari-sdk-docs",
10+
"docs": "turbo run dev --filter=sajari-sdk-docs",
11+
"build:docs": "turbo run build --filter=sajari-sdk-docs",
1212
"start:docs": "turbo run start --filter=sajari-sdk-docs",
1313
"format": "prettier -c --write \"*/**\"",
1414
"lint": "eslint .",
@@ -91,7 +91,7 @@
9191
"typescript": "^4.5.5",
9292
"@types/react": "^17.0.38",
9393
"@types/react-dom": "^17.0.11",
94-
"postcss": "^8.4.5"
94+
"postcss": "^8.4.16"
9595
},
9696
"packageManager": "[email protected]"
9797
}

packages/components/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@
2222
"dist"
2323
],
2424
"peerDependencies": {
25-
"react": ">=16.8.0",
26-
"react-dom": ">=16.8.0"
25+
"react": ">=17",
26+
"react-dom": ">=17"
2727
},
2828
"dependencies": {
29+
"@heroicons/react": "^2.0.8",
2930
"@popperjs/core": "^2.9.2",
3031
"@react-aria/button": "^3.3.0",
3132
"@react-aria/focus": "^3.2.3",

packages/components/src/Button/index.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useButton } from '@react-aria/button';
2-
import { useFocus, useHover } from '@react-aria/interactions';
2+
import { useHover } from '@react-aria/interactions';
33
import { mergeProps } from '@react-aria/utils';
44
import { getStylesObject, mergeRefs } from '@sajari/react-sdk-utils';
55
import classnames from 'classnames';
@@ -28,7 +28,6 @@ const Button = React.forwardRef((props: ButtonProps, ref?: React.Ref<HTMLElement
2828
...rest
2929
} = props;
3030

31-
const [focused, setFocused] = React.useState(false);
3231
const buttonRef = useRef<HTMLElement | null>(null);
3332
const ownRef = mergeRefs(buttonRef, ref);
3433

@@ -39,25 +38,19 @@ const Button = React.forwardRef((props: ButtonProps, ref?: React.Ref<HTMLElement
3938
const { hoverProps, isHovered: hovered } = useHover({
4039
isDisabled: disabled,
4140
});
42-
const { focusProps } = useFocus({
43-
isDisabled: disabled,
44-
onFocus: () => setFocused(true),
45-
onBlur: () => setFocused(false),
46-
});
4741

48-
const { styles: containerStyles, focusRingProps } = useButtonStyles({
42+
const { styles: containerStyles } = useButtonStyles({
4943
pressed,
5044
appearance,
5145
disabled,
5246
fullWidth,
5347
loading,
5448
size,
5549
spacing,
56-
focused,
5750
hovered,
5851
});
5952

60-
const customProps = mergeProps(buttonProps, focusProps, hoverProps, focusRingProps, rest);
53+
const customProps = mergeProps(buttonProps, hoverProps, rest);
6154
const styles = getStylesObject({ container: containerStyles }, disableDefaultStyles);
6255

6356
return (

packages/components/src/Button/styles.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,27 @@ import { css } from '@emotion/core';
22
import { useTheme } from '@sajari/react-sdk-utils';
33
import tw, { TwStyle } from 'twin.macro';
44

5-
import { useFocusRingStyles } from '../hooks';
65
import { ButtonProps } from './types';
76

87
interface UseButtonStylesProps extends ButtonProps {
98
pressed: boolean;
109
hovered: boolean;
11-
focused: boolean;
1210
}
1311

1412
const useButtonStyles = (props: UseButtonStylesProps) => {
15-
const { size, fullWidth, appearance, spacing, disabled, loading, pressed, focused, hovered } = props;
13+
const { size, fullWidth, appearance, spacing, disabled, loading, pressed } = props;
1614
const theme = useTheme();
1715
const isLink = (['link', 'subtle-link'] as Array<ButtonProps['apperance']>).includes(appearance);
1816
const styles: (string | TwStyle)[] = [];
19-
const { focusProps: focusRingProps, focusRingStyles } = useFocusRingStyles();
20-
const returnStyles = (val: typeof styles) => ({ styles: [css(val), focusRingStyles], focusRingProps });
17+
const returnStyles = (val: typeof styles) => ({ styles: [css(val)] });
2118

2219
styles.push(
23-
tw`relative items-center justify-center leading-normal no-underline transition duration-150 ease-in-out border border-transparent border-solid cursor-pointer font-inherit focus:outline-none h-auto`,
20+
tw`relative items-center justify-center h-auto leading-normal no-underline transition duration-150 ease-in-out border border-transparent border-solid rounded-md cursor-pointer font-inherit focus:outline-none`,
21+
`&:focus { box-shadow: 0 0 0 1px #fff, 0 0 0 3px ${theme.color.primary.base} }`,
2422
);
2523

2624
if (!isLink) {
27-
styles.push(tw`font-medium rounded-md select-none`);
25+
styles.push(tw`font-medium select-none`);
2826
}
2927

3028
styles.push(fullWidth ? tw`flex` : tw`inline-flex`);
@@ -117,15 +115,11 @@ const useButtonStyles = (props: UseButtonStylesProps) => {
117115

118116
switch (appearance) {
119117
case 'primary':
120-
styles.push(`color: ${theme.color.primary.text};`);
121-
122-
if (focused || pressed) {
123-
styles.push(`background: ${theme.color.primary.active};`);
124-
} else if (hovered) {
125-
styles.push(`background: ${theme.color.primary.active};`);
126-
} else {
127-
styles.push(`background: ${theme.color.primary.base};`);
128-
}
118+
styles.push(
119+
`color: ${theme.color.primary.text};`,
120+
`background: ${theme.color.primary.base};`,
121+
`&:hover, &:focus, &:hover { background: ${theme.color.primary.active} }`,
122+
);
129123
break;
130124

131125
case 'default':
@@ -144,7 +138,7 @@ const useButtonStyles = (props: UseButtonStylesProps) => {
144138

145139
case 'link':
146140
styles.push(
147-
tw`p-0 no-underline bg-transparent hover:bg-transparent focus:bg-transparent hover:underline focus:underline leading-inherit`,
141+
tw`p-0 no-underline bg-transparent hover:bg-transparent focus:bg-transparent hover:underline focus:underline leading-inherit focus:border-white`,
148142
{
149143
color: pressed ? theme.color.primary.active : theme.color.primary.base,
150144
},
@@ -157,7 +151,7 @@ const useButtonStyles = (props: UseButtonStylesProps) => {
157151

158152
case 'subtle-link':
159153
styles.push(
160-
tw`p-0 no-underline bg-transparent hover:underline focus:underline leading-inherit`,
154+
tw`p-0 no-underline bg-transparent hover:underline focus:underline leading-inherit focus:border-white`,
161155
pressed ? tw`text-gray-700` : tw`text-gray-500`,
162156
);
163157

0 commit comments

Comments
 (0)