Skip to content

Commit 67bac1e

Browse files
authored
feat(components): add support for new guide structure (#58)
* add new guide structure * ensure backwards compatibility and refactor * feat: add support for custom objects carousel title * feat: update styling for shopping and category guides * feat: update styling for comparison guides * feat: add basic error component * cleanup * add js styling and deprecate objects param for headlines * update styles * update read mes and bundlesize * codacy * bundlesize * feat: add contribution guide * cleanup examples * feat: add maxFeaturedItems param * bundlesize
1 parent 068a2aa commit 67bac1e

File tree

27 files changed

+949
-382
lines changed

27 files changed

+949
-382
lines changed

CONTRIBUTING.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
Hello and welcome to the contributing guide for Generative AI Experiences. Thanks for considering participating in our project 🙇
2+
3+
## Reporting an issue
4+
5+
Opening an issue is very effective way to contribute because many users might also be impacted. We'll make sure to fix it quickly if it's technically feasible and doesn't have important side effects for other users.
6+
7+
Before reporting an issue, first check that there is not an already open issue for the same topic using the [issues page](https://github.com/algolia/generative-experiences/issues). Don't hesitate to thumb up an issue that corresponds to the problem you have.
8+
9+
## The code contribution process
10+
11+
Generative AI Experiences is developed in TypeScript.
12+
13+
For any code contribution, you need to:
14+
15+
- Fork and clone the project
16+
- Create a new branch for what you want to solve (fix/_name-of-fix_, feat/_name-of-the-feature_)
17+
- Make your changes
18+
- Open a pull request
19+
20+
Then:
21+
22+
- Peer review of the pull request (by at least one of the core contributors)
23+
- Automatic checks (tests, commits, linters)
24+
- When everything is green, your contribution is merged 🚀
25+
26+
## Commit conventions
27+
28+
This project follows the [conventional changelog](https://conventionalcommits.org/) approach. This means that all commit messages should be formatted using the following scheme:
29+
30+
```
31+
type(scope): description
32+
```
33+
34+
In most cases, we use the following types:
35+
36+
- `fix`: for any resolution of an issue (identified or not)
37+
- `feat`: for any new feature
38+
- `refactor`: for any code change that neither adds a feature nor fixes an issue
39+
- `docs`: for any documentation change or addition
40+
- `chore`: for anything that is not related to the library itself (doc, tooling)
41+
42+
Even though the scope is optional, we try to fill it in as it helps us better understand the impact of a change. We either use the name of the package/component impacted or we use impact topic (e.g. `docs`, `tooling`, `deps`, `ci`).
43+
44+
Finally, if your work is based on an issue on GitHub, please add in the body of the commit message "fix #1234" if it solves the issue #1234 (read "[Closing issues using keywords](https://help.github.com/en/articles/closing-issues-using-keywords)").
45+
46+
Some examples of valid commit messages (used as first lines):
47+
48+
> - fix(client): update getHeadlines parameters
49+
> - chore(deps): update dependency bundlesize to v0.18.4
50+
> - chore: reword contributions guides
51+
52+
## Requirements
53+
54+
To run this project, you will need:
55+
56+
- Node.js ≥ 20.17 (current stable version) – [nvm](https://github.com/creationix/nvm#install-script) is recommended
57+
- [Yarn](https://yarnpkg.com)
58+
59+
## Launch the dev environment
60+
61+
First, build the libraries:
62+
63+
```sh
64+
yarn build
65+
```
66+
67+
Go in the relevant example package an add `.env` file, following the `.env.example`.
68+
Add the information of the Algolia app you want to test the libraries on.
69+
70+
Then start the server of the relevant example:
71+
72+
```sh
73+
yarn --cwd examples/playground yarn dev
74+
```
75+
76+
Finally, go to the URL displayed on the terminal (generally http://localhost:5173) to view the example in a browser.
77+
78+
## Folders of the project
79+
80+
Here are the main files and folders of the project.
81+
82+
```
83+
▸ examples/ << Examples, grouped per flavor
84+
▸ playground/ << React basic example
85+
▸ playground-js/ << JS basic example
86+
▸ packages/ << Packages of the project
87+
▸ generative-experiences-api-client/ << Generative AI Experiences JS API client library
88+
▸ generative-experiences-js/ << The Generative AI Experiences JS library
89+
▸ generative-experiences-react/ << The Generative AI Experiences React library
90+
▸ generative-experiences-vdom/ << The primitives for building flavors of the Generative AI Experiences widgets
91+
▸ test/ << The test utilites
92+
▸ utils/ << Global utilities for the tests
93+
▸ scripts/ << The scripts for maintaining the project
94+
CHANGELOG.md << The autogenerated changelog (based on commits)
95+
CONTRIBUTING.md << this file
96+
package.json << The definition of the project
97+
README.md << The introduction of the project
98+
```
99+
100+
## Release
101+
102+
### Main version
103+
104+
To release a stable version, go on `master` (`git checkout master`) and use:
105+
106+
```sh
107+
yarn run release
108+
```
109+
110+
It will create a pull request for the next release. When it's reviewed, approved and merged, then CircleCI will automatically publish it to npm.

bundlesize.config.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22
"files": [
33
{
44
"path": "packages/generative-experiences-api-client/dist/index.js",
5-
"maxSize": "27.59 kB"
5+
"maxSize": "27.9 kB"
66
},
77
{
88
"path": "packages/generative-experiences-api-client/dist/index.umd.js",
9-
"maxSize": "11.55 kB"
9+
"maxSize": "11.73 kB"
1010
},
1111
{
1212
"path": "packages/generative-experiences-vdom/dist/index.js",
13-
"maxSize": "18.3 kB"
13+
"maxSize": "4 kB"
1414
},
1515
{
1616
"path": "packages/generative-experiences-vdom/dist/index.umd.js",
17-
"maxSize": "14.9 kB"
17+
"maxSize": "3.3 kB"
1818
},
1919
{
2020
"path": "packages/generative-experiences-react/dist/index.js",
21-
"maxSize": "19.6 kB"
21+
"maxSize": "4.62 kB"
2222
},
2323
{
2424
"path": "packages/generative-experiences-react/dist/index.umd.js",
25-
"maxSize": "15.9 kB"
25+
"maxSize": "3.76 kB"
2626
},
2727
{
2828
"path": "packages/generative-experiences-js/dist/index.js",
29-
"maxSize": "19.6 kB"
29+
"maxSize": "11.3 kB"
3030
},
3131
{
3232
"path": "packages/generative-experiences-js/dist/index.umd.js",
33-
"maxSize": "15.9 kB"
33+
"maxSize": "9.57 kB"
3434
}
3535
]
3636
}

examples/playground-js/index.css

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
.ais-NoWrap {
6+
@apply whitespace-nowrap;
7+
}
8+
9+
.ais-ScreenReaderOnly {
10+
@apply sr-only;
11+
}
12+
13+
/* display headlines */
14+
.ais-GuideHeadlinesContent-wrapper {
15+
@apply rounded p-4 border border-gray-100 shadow gap-2;
16+
}
17+
18+
.ais-GuideHeadlinesContent-container {
19+
@apply flex flex-col items-end;
20+
}
21+
22+
.ais-GuideHeadlinesContent-itemsContainer {
23+
@apply flex items-center gap-6;
24+
}
25+
26+
.ais-GuideHeadlinesContent-readMore {
27+
@apply flex text-white py-2 mt-8 border-2 bg-blue-700 rounded-md items-center w-full justify-center;
28+
}
29+
30+
.ais-GuideHeadlinesContent-item {
31+
@apply bg-neutral-100 rounded p-4 space-y-3 flex justify-between min-h-[420px];
32+
}
33+
34+
.ais-GuideHeadlinesContent-itemContent {
35+
@apply mt-5;
36+
}
37+
38+
.ais-GuideHeadlinesContent-itemTitle {
39+
@apply text-blue-800 font-semibold line-clamp-2 h-12;
40+
}
41+
42+
.ais-GuideHeadlinesContent-itemDescription {
43+
@apply line-clamp-4 text-base mt-2;
44+
}
45+
46+
.ais-GuideHeadlinesContent-itemImage {
47+
@apply relative min-h-[120px] max-h-[120px] w-auto overflow-hidden mx-auto mt-4 aspect-square;
48+
}
49+
50+
/* display content */
51+
.ais-GuideContent-contentSection {
52+
@apply prose max-w-prose mx-auto px-4;
53+
}
54+
55+
.ais-GuideContent {
56+
@apply mb-10 w-full;
57+
}
58+
59+
.ais-GuideContent-heroImage {
60+
@apply mx-auto min-h-[200px] max-h-[250px] my-12;
61+
}
62+
63+
.ais-GuideContent .ais-Feedback {
64+
@apply flex items-end justify-end mx-auto;
65+
}
66+
67+
.ais-GuideContent-factorsList {
68+
@apply flex flex-wrap list-disc gap-x-2 justify-between w-full;
69+
}
70+
71+
.ais-GuideContent-factorItem {
72+
@apply w-[45%];
73+
}
74+
75+
.ais-GuideContent-relatedItemsSection {
76+
@apply prose max-w-none mx-auto px-4;
77+
}
78+
79+
.ais-GuideContent-relatedItemsTitle {
80+
@apply max-w-prose mx-auto px-4;
81+
}
82+
83+
.ais-GuideContent-relatedItemsListContainer {
84+
@apply max-w-prose mx-auto px-4;
85+
}
86+
87+
.ais-GuideContent-relatedItemsList {
88+
@apply p-2 flex justify-between flex-wrap list-none;
89+
}
90+
91+
/* display feedback */
92+
.ais-Feedback {
93+
@apply text-gray-500 text-base max-w-prose mt-10;
94+
}
95+
96+
.ais-feedbackContainer {
97+
@apply flex items-center gap-4;
98+
}
99+
100+
.ais-Feedback-thanksWrapper {
101+
@apply flex items-center;
102+
}
103+
104+
.ais-Feedback-labelWrapper {
105+
@apply flex space-x-2 items-center;
106+
}
107+
108+
.ais-Feedback-labelIcon {
109+
@apply h-6 w-6 flex-shrink-0;
110+
}
111+
112+
.ais-Feedback-button {
113+
@apply inline-block rounded font-semibold text-center shadow-sm transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 bg-white hover:bg-white border-2 border-gray-400 hover:border-gray-500 focus-visible:outline-gray-500 text-gray-400 hover:text-gray-500 px-2.5 py-1.5;
114+
}
115+
116+
.ais-Feedback-buttonsWrapper {
117+
@apply flex space-x-3 items-center;
118+
}
119+
120+
.ais-Feedback-buttonIcon {
121+
@apply h-4 w-4 stroke-2 flex-shrink-0;
122+
}
123+
124+
/* error loading guide */
125+
.ais-GuideContentError {
126+
@apply flex flex-col items-center text-center gap-y-4 max-w-prose mx-auto my-6;
127+
}
128+
129+
.ais-GuideContentErrorTitle {
130+
@apply text-lg font-semibold;
131+
}

examples/playground-js/index.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@
44
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
55

66
<link rel="shortcut icon" href="favicon.png" type="image/x-icon" />
7-
<link
8-
href="https://unpkg.com/tailwindcss@2/dist/tailwind.min.css"
9-
rel="stylesheet"
10-
/>
11-
<!-- <link rel="stylesheet" href="app.css" />
12-
<link rel="stylesheet" href="Recommend.css" /> -->
7+
<link rel="stylesheet" href="index.css" />
138

149
<title>Algolia JavaScript GSE</title>
1510
</head>
1611

1712
<body>
1813
<div class="container">
19-
<h1>Algolia GSE</h1>
14+
<h1 class="text-lg font-semibold">Algolia Generative Experiences Guides</h1>
2015

2116
<div id="headlines"></div>
2217
<div id="content"></div>

examples/playground-js/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
"dependencies": {
2323
"@algolia/generative-experiences-api-client": "1.6.0",
2424
"@algolia/generative-experiences-js": "1.6.0",
25-
"@algolia/generative-experiences-vdom": "1.6.0"
25+
"@algolia/generative-experiences-vdom": "1.6.0",
26+
"@tailwindcss/typography": "^0.5.9",
27+
"autoprefixer": "10.4.20",
28+
"postcss": "8.4.49",
29+
"tailwindcss": "3.3.2"
2630
},
2731
"devDependencies": {
2832
"preact": "^10.25.1"

examples/playground-js/src/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ const options = {
1919
};
2020

2121
const client = createClient(options);
22+
/* Test JS widgets, replace 'objectID', 'category' and 'userToken' parameters */
2223

2324
guidesHeadlines({
2425
container: '#headlines',
2526
client,
2627
userToken: 'test-user',
2728
showImmediate: true,
28-
// showFeedback: true,
29+
onlyPublished: false,
30+
showFeedback: true,
2931
category: 'category',
3032
});
3133

@@ -41,8 +43,10 @@ guideContent<RecordType>({
4143
client,
4244
onlyPublished: false,
4345
itemComponent({ hit }) {
46+
/* Add custom itemComponent to reflect your use case */
4447
return <div>{hit.title}</div>;
4548
},
49+
showFeedback: true,
4650
objectID: '123',
4751
userToken: 'test-user',
4852
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @type {import('tailwindcss').Config} */
2+
3+
module.exports = {
4+
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
5+
theme: {
6+
extend: {},
7+
},
8+
plugins: [require('@tailwindcss/typography')],
9+
};

examples/playground-js/vite.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'path';
22

33
import preact from '@preact/preset-vite';
4+
import tailwindcss from '@vituum/vite-plugin-tailwindcss';
45
import { defineConfig } from 'vite';
56
import dts from 'vite-plugin-dts';
67

@@ -11,6 +12,7 @@ export default defineConfig({
1112
rollupTypes: true,
1213
}),
1314
preact(),
15+
tailwindcss(),
1416
],
1517
optimizeDeps: { esbuildOptions: { jsx: 'automatic' } },
1618
build: {

0 commit comments

Comments
 (0)