Skip to content

Commit

Permalink
Merge pull request #81 from oramasearch/feature/orm-2229
Browse files Browse the repository at this point in the history
ORM-2229: Expose border radius and box shadow of text area in chatbox
  • Loading branch information
rjborba authored Feb 13, 2025
2 parents e3db2a9 + 50d40f0 commit cb8ce68
Show file tree
Hide file tree
Showing 15 changed files with 13,524 additions and 11,630 deletions.
6 changes: 6 additions & 0 deletions apps/storybook/stories/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ const demoIndexes: DemoIndexConfig = {
'--backdrop-background-color-primary': 'rgba(20, 3, 3, 0.7)',
},
},
radius: {
'--textarea-radius': '0.5rem',
},
shadow: {
'--textarea-shadow': 'none',
},
},
facetProperty: 'category',
resultMap: {
Expand Down
8 changes: 8 additions & 0 deletions apps/storybook/stories/public/orama-chat-box.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,13 @@ export const ChatBox: Story = {
args: {
preset: 'orama',
colorScheme: 'dark',
themeConfig: {
radius: {
// "--textarea-radius": '0px'
},
shadow: {
// "--textarea-shadow": '0px 4px 24px 0px white'
},
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
position: relative;
display: flex;
align-items: center;
border-radius: var(--radius-l, $radius-l);
border-radius: var(--textarea-radius, var(--radius-l, $radius-l));
border: 1px solid var(--border-color-primary, border-color('primary'));
background: var(--background-color-secondary, background-color('secondary'));
box-shadow: 0px 4px 24px 0px var(--shadow-color-primary, shadow-color('primary'));
box-shadow: var(--textarea-shadow, var(--shadow-color-primary, shadow-color('primary')));
padding: var(--spacing-xs, $spacing-xs) var(--spacing-xs, $spacing-xs) var(--spacing-xs, $spacing-xs) var(--spacing-m, $spacing-m);
}

Expand Down
38 changes: 19 additions & 19 deletions packages/ui-stencil/src/components/orama-chat-box/readme.md

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions packages/ui-stencil/src/components/orama-search-box/readme.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions packages/ui-stencil/src/components/orama-search-button/readme.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions packages/ui-stencil/src/config/radius.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const radius = {
'--radius-xs': '6px',
'--radius-s': '8px',
'--radius-m': '12px',
'--radius-l': '16px',
'--radius-3xl': '40px',
'--textarea-radius': '16px',
}

export default radius
5 changes: 5 additions & 0 deletions packages/ui-stencil/src/config/shadow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const shadow = {
'--textarea-shadow': undefined,
}

export default shadow
4 changes: 4 additions & 0 deletions packages/ui-stencil/src/config/theme.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import colors from './colors'
import typography from './typography'
import radius from './radius'
import shadow from './shadow'

const theme = {
typography,
colors,
radius,
shadow,
}

type TTheme = typeof theme
Expand Down
9 changes: 8 additions & 1 deletion packages/ui-stencil/src/styles/_radius.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ $radius-s: pxToRem($base);
$radius-m: pxToRem($base * 1.5);
$radius-l: pxToRem($base * 2);
$radius-3xl: pxToRem($base * 5);
$textarea-radius: $radius-l;

$theme-radius: (
$base-radius: (
'--radius-xs': $radius-xs,
'--radius-s': $radius-s,
'--radius-m': $radius-m,
'--radius-l': $radius-l,
'--radius-3xl': $radius-3xl,
);

$element-radius: (
'--textarea-radius': $textarea-radius,
);

$theme-radius: map-merge($base-radius, $element-radius);
8 changes: 8 additions & 0 deletions packages/ui-stencil/src/styles/_shadow.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$base-shadow: (
);

$element-shadow: (
'--textarea-shadow': 0px 4px 24px 0px var(--shadow-color-primary, shadow-color('primary')),
);

$theme-shadow: map-merge($base-shadow, $element-shadow);
1 change: 1 addition & 0 deletions packages/ui-stencil/src/styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
@import 'typography';
@import 'spacing';
@import 'radius';
@import 'shadow';
@import 'zindex';
1 change: 1 addition & 0 deletions packages/ui-stencil/src/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@include mapToCustomProperties($theme-typography);
@include mapToCustomProperties($theme-radius);
@include mapToCustomProperties($theme-spacing);
@include mapToCustomProperties($theme-shadow);

*,
*:before,
Expand Down
28 changes: 13 additions & 15 deletions packages/ui-stencil/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function generateRandomID(componentName: string): string {
export function updateThemeClasses(
element: HTMLElement,
colorScheme: ColorScheme,
systemScheme: Omit<ColorScheme, 'system'>
systemScheme: Omit<ColorScheme, 'system'>,
) {
const scheme = colorScheme === 'system' ? systemScheme : colorScheme

Expand All @@ -141,22 +141,20 @@ export function updateThemeClasses(
return scheme
}

export function updateCssVariables(
element: HTMLElement,
scheme: ColorScheme,
themeConfig?: Partial<TThemeOverrides>
) {
export function updateCssVariables(element: HTMLElement, scheme: ColorScheme, themeConfig?: Partial<TThemeOverrides>) {
if (!element || !themeConfig || !scheme) return

if (themeConfig.colors?.[scheme]) {
for (const key of Object.keys(themeConfig.colors[scheme])) {
element.style.setProperty(`${key}`, themeConfig.colors[scheme][key])
}
}

if (themeConfig.typography) {
for (const key of Object.keys(themeConfig.typography)) {
element.style.setProperty(`${key}`, themeConfig.typography[key])
for (const base of Object.keys(themeConfig)) {
if (base === 'colors') {
if (themeConfig[base]?.[scheme]) {
for (const key of Object.keys(themeConfig[base][scheme])) {
element.style.setProperty(`${key}`, themeConfig[base][scheme][key])
}
}
} else {
for (const key of Object.keys(themeConfig[base])) {
element.style.setProperty(`${key}`, themeConfig[base][key])
}
}
}
}
Loading

0 comments on commit cb8ce68

Please sign in to comment.