Skip to content

Commit

Permalink
cleanup: lint CI with configs
Browse files Browse the repository at this point in the history
  • Loading branch information
SaraVieira authored and skeptrunedev committed Aug 31, 2024
1 parent 74e736d commit d732771
Show file tree
Hide file tree
Showing 15 changed files with 325 additions and 77 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ts-sdk-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Deploy TS-SDK docs to github pages
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build:
Expand Down
42 changes: 0 additions & 42 deletions clients/search-component/.eslintrc.json

This file was deleted.

47 changes: 47 additions & 0 deletions clients/search-component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,53 @@ export const trieve = new TrieveSDK({
});
```

And then you can use any of the two components in your React application or as web component:

### Search Modal

<details>
<summary>Screenshots</summary>

![light closed](./github/modal-light-1.png)
![dark closed](./github/modal-dark-1.png)
![light open](./github/modal-light-2.png)

</details>

#### Usage in React:

```jsx
<TrieveModalSearch trieve={trieve} />
```

#### Usage in Web Components:

```html
<trieve-modal-search trieve="<your trieve instance>" />
```

### Search Results

<details>
<summary>Screenshots</summary>

![light](./github/search-light.png)
![dark](./github/search-dark.png)

</details>

#### Usage in React:

```jsx
<TrieveSearch trieve={trieve} />
```

#### Usage in Web Components:

```html
<trieve-search trieve="<your trieve instance>" />
```

## License

MIT
10 changes: 10 additions & 0 deletions clients/search-component/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{ ignores: ["**/*.js", "**/*.cjs"] }
);
Binary file added clients/search-component/github/modal-dark-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added clients/search-component/github/search-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added clients/search-component/github/search-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions clients/search-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,30 @@
"dist/*",
"dist/**/*"
],
"version": "0.0.1",
"version": "0.0.1-rc1",
"license": "MIT",
"scripts": {
"dev": "run-p watch:css watch:js",
"watch:css": "npx postcss src/app.css -o dist/app.css --watch",
"watch:js": "node ./scripts/watch.js",
"lint": "eslint 'src/**/*.ts'",
"lint": "eslint",
"build:clean": "rm tsconfig.tsbuildinfo && rm -rf dist && yarn type:gen && yarn build",
"build": "run-s build:src build:css type:dts",
"build:src": "node ./scripts/build.js",
"type:dts": "tsc --emitDeclarationOnly --declarationMap",
"build:css": "npx postcss src/app.css -o dist/app.css "
},
"devDependencies": {
"@eslint/js": "^9.9.1",
"@tailwindcss/forms": "^0.5.7",
"@types/eslint__js": "^8.42.3",
"@types/lodash-es": "^4.17.12",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"esbuild": "^0.23.1",
"esbuild-node-externals": "^1.14.0",
"esbuild-register": "^3.6.0",
"eslint": "^9.9.1",
"eslint-plugin-react": "^7.35.0",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.41",
Expand All @@ -38,7 +41,8 @@
"react-dom": "^18.3.1",
"tailwind": "^4.0.0",
"tailwindcss": "^3.4.10",
"typescript": "^5.5.4"
"typescript": "^5.5.4",
"typescript-eslint": "^8.3.0"
},
"dependencies": {
"@r2wc/react-to-web-component": "^2.0.3",
Expand Down
35 changes: 17 additions & 18 deletions clients/search-component/src/TrieveModal/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,29 @@ body {
@apply font-normal text-xs text-zinc-600;
}
}
}

&.dark {
.kbd-wrapper {
kbd {
@apply border-zinc-400 text-zinc-400;
&.dark {
.kbd-wrapper {
kbd {
@apply border-zinc-400 text-zinc-400;
}
}
}

@apply text-white bg-zinc-900;
@apply text-white bg-zinc-900;

input {
@apply bg-zinc-900 text-zinc-50 ring-zinc-700;
}
input {
@apply bg-zinc-900 text-zinc-50 ring-zinc-700;
}

.input-wrapper {
@apply bg-zinc-900;
}
.input-wrapper {
@apply bg-zinc-900;
}

.item {
@apply hover:bg-zinc-800 border-zinc-700 focus:bg-zinc-800 bg-zinc-900;
.item {
@apply hover:bg-zinc-800 border-zinc-700 focus:bg-zinc-800 bg-zinc-900;

.description {
@apply text-zinc-400;
.description {
@apply text-zinc-400;
}
}
}
}
Expand Down
16 changes: 10 additions & 6 deletions clients/search-component/src/TrieveModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,19 @@ export const TrieveModalSearch = ({

const onUpOrDownClicked = (index: number, code: string) => {
if (code === "ArrowDown") {
index < results.length - 1
? document.getElementById(`trieve-search-item-${index + 1}`)?.focus()
: document.getElementById(`trieve-search-item-0`)?.focus();
if (index < results.length - 1) {
document.getElementById(`trieve-search-item-${index + 1}`)?.focus();
} else {
document.getElementById(`trieve-search-item-0`)?.focus();
}
}

if (code === "ArrowUp") {
index > 0
? document.getElementById(`trieve-search-item-${index - 1}`)?.focus()
: inputRef.current?.focus();
if (index > 0) {
document.getElementById(`trieve-search-item-${index - 1}`)?.focus();
} else {
inputRef.current?.focus();
}
}
};

Expand Down
1 change: 1 addition & 0 deletions clients/search-component/src/TrieveModal/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const Item = ({
onUpOrDownClicked,
}: Props) => {
const Component = item.chunk.link ? "a" : "button";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const itemRef = useRef<HTMLButtonElement | HTMLLinkElement | any>(null);
const title =
item.chunk.metadata?.title ||
Expand Down
1 change: 1 addition & 0 deletions clients/search-component/src/TrieveSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const TrieveSearch = ({
} else {
onResultClick?.(state.selectedItem?.chunk as Chunk);
}
return state;
}
case useCombobox.stateChangeTypes.InputBlur: {
return {
Expand Down
Loading

0 comments on commit d732771

Please sign in to comment.