1
0
Fork 0
docsearch/packages/docsearch-css/build-css.js
Paul Jankowski 171c504f11
feat(sidepanel): Introduce Ask AI Sidepanel (#2816)
* feat(sidepanel): Add sidepanel component for Ask AI (#2792)

* feat(sidepanel): Initial working Sidepanel implementation

* fix: circleci config

* fix: set proper sidepanel export

* Sidepanel props updates, conversation screen updates

* Started mobile work

* Style prompt input and header for mobile

* fixes prompt input height, adds more translations, mobile updates, fixes panel height calculations

* finish mobile, adds dark theme, minor fixes

* fix: lock

* Add missing titles to buttons

* Have most recent conversation be at the bottom of the exchange list, scroll to newest conversation

* fix: versions

* move to floating variant being default for Sidepanel

---------

Co-authored-by: Dylan Tientcheu <dylantientcheu@gmail.com>

* feat(sidepanel): Sidepanel/Modal hybrid mode (#2799)

* feat(sidepanel): Initial working Sidepanel implementation

* fix: circleci config

* fix: set proper sidepanel export

* Sidepanel props updates, conversation screen updates

* Started mobile work

* Style prompt input and header for mobile

* fixes prompt input height, adds more translations, mobile updates, fixes panel height calculations

* finish mobile, adds dark theme, minor fixes

* fix: lock

* Add missing titles to buttons

* Have most recent conversation be at the bottom of the exchange list, scroll to newest conversation

* feat(sidepanel): Allow hybrid mode for Sidepanel and Modal

* fix: yarn.lock

* fix: tests - dont send new chat message from modal while in hybrid mode

* Make docsearch core a true dependency

* Cleanup handling the registered views Set

---------

Co-authored-by: Dylan Tientcheu <dylantientcheu@gmail.com>

* feat(sidepanel): Add sidepanel-js package for CDN (#2800)

* feat(sidepanel): Initial working Sidepanel implementation

* fix: circleci config

* fix: set proper sidepanel export

* Sidepanel props updates, conversation screen updates

* Started mobile work

* Style prompt input and header for mobile

* fixes prompt input height, adds more translations, mobile updates, fixes panel height calculations

* finish mobile, adds dark theme, minor fixes

* fix: lock

* Add missing titles to buttons

* Have most recent conversation be at the bottom of the exchange list, scroll to newest conversation

* feat(sidepanel): Add sidepanel-js package for CDN

* fix: ci

* fix: yarn.lock

---------

Co-authored-by: Dylan Tientcheu <dylantientcheu@gmail.com>

* feat(sidepanel): Sidepanel UI/UX tweaks (#2808)

* fix(umd): Fixes global names for packages in UMD builds

* chore: Update tsdeclaration files, update directory field in package json files

* feat(sidepanel): Add Sidepanel documentation (#2811)

* feat(sidepanel): Add Sidepanel documentation

* Minor fixes and updates

* Hybrid mode update

* fix: hardcode yarn cache key for now

---------

Co-authored-by: Dylan Tientcheu <dylantientcheu@gmail.com>
2025-12-17 13:25:50 -05:00

109 lines
3.1 KiB
JavaScript

/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable import/no-commonjs, import/no-extraneous-dependencies */
const { execSync } = require('child_process');
const fs = require('fs');
const util = require('util');
const cssnano = require('cssnano');
const postcss = require('postcss');
const pkg = require('./package.json');
const readFile = util.promisify(fs.readFile);
function getBundleBanner(_pkg) {
const lastCommitHash = execSync('git rev-parse --short HEAD').toString().trim();
const version = process.env.SHIPJS ? _pkg.version : `${_pkg.version} (UNRELEASED ${lastCommitHash})`;
const authors = '© Algolia, Inc. and contributors';
return `/*! ${_pkg.name} ${version} | MIT License | ${authors} | ${_pkg.homepage} */`;
}
function build({ input, output, banner }) {
fs.readFile(input, (error, css) => {
if (error) {
throw error;
}
postcss([cssnano])
.process(css, { from: input, to: output })
.then((result) => {
fs.writeFile(output, [banner, result.css].join('\n'), () => true);
});
});
}
build({
input: 'src/_variables.css',
output: 'dist/_variables.css',
banner: getBundleBanner({ ...pkg, name: `${pkg.name} Variables` }),
});
build({
input: 'src/button.css',
output: 'dist/button.css',
banner: getBundleBanner({ ...pkg, name: `${pkg.name} Button` }),
});
build({
input: 'src/modal.css',
output: 'dist/modal.css',
banner: getBundleBanner({ ...pkg, name: `${pkg.name} Modal` }),
});
async function buildStyle() {
const variablesCss = await readFile('src/_variables.css');
const buttonCss = await readFile('src/button.css');
const modalCss = await readFile('src/modal.css');
const variablesOutput = await postcss([cssnano]).process(variablesCss, {
from: undefined,
});
const buttonOutput = await postcss([cssnano]).process(buttonCss, {
from: undefined,
});
const modalOutput = await postcss([cssnano]).process(modalCss, {
from: undefined,
});
fs.writeFile(
'dist/style.css',
[getBundleBanner(pkg), [variablesOutput.css, buttonOutput.css, modalOutput.css].join('')].join('\n'),
() => true,
);
fs.writeFile(
'dist/style.scss',
[getBundleBanner(pkg), [variablesOutput.css, buttonOutput.css, modalOutput.css].join('')].join('\n'),
() => true,
);
}
async function buildSidepanel() {
const variablesCss = await readFile('src/_variables.css');
const sidepanelCss = await readFile('src/sidepanel.css');
const [variablesOutput, sidepanelOutput] = await Promise.all([
postcss([cssnano]).process(variablesCss, { from: undefined }),
postcss([cssnano]).process(sidepanelCss, { from: undefined }),
]);
fs.writeFile(
'dist/sidepanel.css',
[
getBundleBanner({ ...pkg, name: `${pkg.name} Sidepanel` }),
[variablesOutput.css, sidepanelOutput.css].join(''),
].join('\n'),
() => true,
);
fs.writeFile(
'dist/sidepanel.scss',
[
getBundleBanner({ ...pkg, name: `${pkg.name} Sidepanel` }),
[variablesOutput.css, sidepanelOutput.css].join(''),
].join('\n'),
() => true,
);
}
Promise.all([buildStyle(), buildSidepanel()]);