Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for borealis theme #202393

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import React from 'react';
import styled from '@emotion/styled';
import { euiThemeVars } from '@kbn/ui-theme';
import { AssistantAvatar } from './assistant_avatar/assistant_avatar';

const Container = styled.div`
Expand All @@ -18,8 +17,8 @@ const Container = styled.div`
display: flex;
justify-content: center;
align-items: center;
margin-top: ${euiThemeVars.euiSizeXXL};
margin-bottom: ${euiThemeVars.euiSizeL};
margin-top: ${(props) => props.theme.euiTheme.size.xxl};
margin-bottom: ${(props) => props.theme.euiTheme.size.xxl};

:before,
:after {
Expand All @@ -45,7 +44,7 @@ const Animation = styled.div`
top: 0;
left: 0;
z-index: 0;
border: 1px solid ${euiThemeVars.euiColorPrimary};
border: 1px solid ${(props) => props.theme.euiTheme.colors.borderBasePlain};
border-radius: inherit;
animation: 4s cubic-bezier(0.42, 0, 0.37, 1) 0.5s infinite normal none running pulsing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ import React, {
useMemo,
useRef,
} from 'react';
import { EuiEmptyPrompt, EuiFlexGroup, EuiFlexItem, EuiPanel, EuiText } from '@elastic/eui';
import {
EuiEmptyPrompt,
EuiFlexGroup,
EuiFlexItem,
EuiPanel,
EuiText,
useEuiTheme,
} from '@elastic/eui';
import { HttpSetup } from '@kbn/core-http-browser';
import { euiThemeVars } from '@kbn/ui-theme';
import { css } from '@emotion/react';
import { PromptResponse } from '@kbn/elastic-assistant-common';
import { AssistantAnimatedIcon } from '../assistant_animated_icon';
Expand Down Expand Up @@ -53,6 +59,8 @@ export const AssistantBody: FunctionComponent<Props> = ({
isWelcomeSetup,
setIsSettingsModalVisible,
}) => {
const { euiTheme } = useEuiTheme();

const isEmptyConversation = useMemo(
() => currentConversation?.messages.length === 0,
[currentConversation?.messages.length]
Expand All @@ -64,16 +72,16 @@ export const AssistantBody: FunctionComponent<Props> = ({
<EuiText
data-test-subj="assistant-disclaimer"
textAlign="center"
color={euiThemeVars.euiColorMediumShade}
color={euiTheme.colors.backgroundBaseFormsControlDisabled}
size="xs"
css={css`
margin: 0 ${euiThemeVars.euiSizeL} ${euiThemeVars.euiSizeM} ${euiThemeVars.euiSizeL};
margin: 0 ${euiTheme.size.l} ${euiTheme.size.m} ${euiTheme.size.l};
`}
>
{i18n.DISCLAIMER}
</EuiText>
),
[isEmptyConversation]
[euiTheme, isEmptyConversation]
);

// Start Scrolling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
EuiPanel,
EuiToolTip,
EuiSkeletonTitle,
useEuiTheme,
} from '@elastic/eui';
import { css } from '@emotion/react';
import { euiThemeVars } from '@kbn/ui-theme';
import { isEmpty } from 'lodash';
import { DataStreamApis } from '../use_data_stream_apis';
import { Conversation } from '../../..';
Expand Down Expand Up @@ -79,6 +79,8 @@ export const AssistantHeader: React.FC<Props> = ({
isAssistantEnabled,
refetchPrompts,
}) => {
const { euiTheme } = useEuiTheme();

const showAnonymizedValuesChecked = useMemo(
() =>
selectedConversation?.replacements != null &&
Expand Down Expand Up @@ -148,8 +150,8 @@ export const AssistantHeader: React.FC<Props> = ({
hasShadow={false}
paddingSize="m"
css={css`
padding-top: ${euiThemeVars.euiSizeS};
padding-bottom: ${euiThemeVars.euiSizeS};
padding-top: ${euiTheme.size.s};
padding-bottom: ${euiTheme.size.s};
`}
>
<EuiFlexGroup alignItems={'center'} justifyContent={'spaceBetween'} gutterSize="s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
*/

import React, { memo, useCallback, useMemo } from 'react';
import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiButtonIcon, EuiButtonEmpty } from '@elastic/eui';
import {
EuiPanel,
EuiFlexGroup,
EuiFlexItem,
EuiButtonIcon,
EuiButtonEmpty,
useEuiTheme,
} from '@elastic/eui';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { i18n } from '@kbn/i18n';
import { euiThemeVars } from '@kbn/ui-theme';
import { NEW_CHAT } from '../conversations/conversation_sidepanel/translations';

export interface FlyoutNavigationProps {
Expand All @@ -26,7 +32,7 @@ const VerticalSeparator = styled.div`
:before {
content: '';
height: 100%;
border-left: 1px solid ${euiThemeVars.euiColorLightShade};
border-left: 1px solid ${(props) => props.theme.euiTheme.colors.borderBasePlain};
}
`;

Expand All @@ -44,6 +50,8 @@ export const FlyoutNavigation = memo<FlyoutNavigationProps>(
onConversationCreate,
isAssistantEnabled,
}) => {
const { euiTheme } = useEuiTheme();

const onToggle = useCallback(
() => setIsExpanded && setIsExpanded(!isExpanded),
[isExpanded, setIsExpanded]
Expand Down Expand Up @@ -84,7 +92,7 @@ export const FlyoutNavigation = memo<FlyoutNavigationProps>(
paddingSize="s"
grow={false}
css={css`
border-bottom: 1px solid ${euiThemeVars.euiColorLightShade};
border-bottom: 1px solid ${euiTheme.colors.borderBasePlain};
`}
>
<EuiFlexGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import React, { useCallback, useEffect, useMemo, useRef } from 'react';
import { css } from '@emotion/react';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { euiThemeVars } from '@kbn/ui-theme';
import { EuiFlexGroup, EuiFlexItem, useEuiTheme } from '@elastic/eui';
import { UseChatSend } from './use_chat_send';
import { ChatActions } from '../chat_actions';
import { PromptTextArea } from '../prompt_textarea';
Expand All @@ -32,6 +31,10 @@ export const ChatSend: React.FC<Props> = ({
shouldRefocusPrompt,
userPrompt,
}) => {
const { euiTheme } = useEuiTheme();

console.error('eui', euiTheme);

// For auto-focusing prompt within timeline
const promptTextAreaRef = useRef<HTMLTextAreaElement>(null);
useEffect(() => {
Expand Down Expand Up @@ -77,9 +80,9 @@ export const ChatSend: React.FC<Props> = ({
css={css`
right: 0;
position: absolute;
margin-right: ${euiThemeVars.euiSizeS};
margin-bottom: ${euiThemeVars.euiSizeS};
`}
// margin-right: ${euiTheme.size.s};
// margin-bottom: ${euiTheme.size.s};
grow={false}
>
<ChatActions
Expand Down
12 changes: 7 additions & 5 deletions x-pack/packages/kbn-elastic-assistant/impl/assistant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
EuiFlyoutFooter,
EuiFlyoutHeader,
EuiFlyoutBody,
useEuiTheme,
} from '@elastic/eui';
import { euiThemeVars } from '@kbn/ui-theme';
import { createPortal } from 'react-dom';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
Expand Down Expand Up @@ -79,6 +79,7 @@ const AssistantComponent: React.FC<Props> = ({
setChatHistoryVisible,
shouldRefocusPrompt = false,
}) => {
const { euiTheme } = useEuiTheme();
const {
assistantAvailability: { isAssistantEnabled },
assistantTelemetry,
Expand Down Expand Up @@ -378,7 +379,7 @@ const AssistantComponent: React.FC<Props> = ({
})}
// Avoid comments going off the flyout
css={css`
padding-bottom: ${euiThemeVars.euiSizeL};
padding-bottom: ${euiTheme.size.l};

> li > div:nth-child(2) {
overflow: hidden;
Expand All @@ -402,6 +403,7 @@ const AssistantComponent: React.FC<Props> = ({
setIsStreaming,
currentUserAvatar,
currentSystemPrompt?.content,
euiTheme.size.l,
selectedPromptContextsCount,
]
);
Expand All @@ -425,7 +427,7 @@ const AssistantComponent: React.FC<Props> = ({
grow={false}
css={css`
inline-size: ${CONVERSATION_SIDE_PANEL_WIDTH}px;
border-right: 1px solid ${euiThemeVars.euiColorLightShade};
border-right: 1px solid ${euiTheme.colors.borderBasePlain};
`}
>
<ConversationSidePanel
Expand Down Expand Up @@ -531,7 +533,7 @@ const AssistantComponent: React.FC<Props> = ({
<EuiFlyoutFooter
css={css`
background: none;
border-top: 1px solid ${euiThemeVars.euiColorLightShade};
border-top: 1px solid ${euiTheme.colors.borderBasePlain};
overflow: hidden;
max-height: 60%;
display: flex;
Expand Down Expand Up @@ -591,7 +593,7 @@ const AssistantComponent: React.FC<Props> = ({
{!isDisabled && (
<EuiPanel
css={css`
background: ${euiThemeVars.euiColorLightestShade};
background: ${euiTheme.colors.lightestShade};
`}
hasShadow={false}
paddingSize="m"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
* 2.0.
*/

import { EuiAccordion, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';
import {
EuiAccordion,
EuiButtonIcon,
EuiFlexGroup,
EuiFlexItem,
EuiToolTip,
useEuiTheme,
} from '@elastic/eui';
import { isEmpty, omit } from 'lodash/fp';
import React, { useCallback } from 'react';
import { css } from '@emotion/react';
import { euiThemeVars } from '@kbn/ui-theme';
import { Conversation } from '../../../assistant_context/types';
import { DataAnonymizationEditor } from '../../../data_anonymization_editor';
import type { PromptContext, SelectedPromptContext } from '../../prompt_context/types';
Expand All @@ -30,6 +36,8 @@ const SelectedPromptContextsComponent: React.FC<Props> = ({
setSelectedPromptContexts,
currentReplacements,
}) => {
const { euiTheme } = useEuiTheme();

const unselectPromptContext = useCallback(
(unselectedId: string) => {
setSelectedPromptContexts((prev) => omit(unselectedId, prev));
Expand Down Expand Up @@ -64,13 +72,14 @@ const SelectedPromptContextsComponent: React.FC<Props> = ({
}
id={id}
paddingSize="s"
// background: ${euiTheme.colors.backgroundPage};
css={css`
background: ${euiThemeVars.euiPageBackgroundColor};
border-radius: ${euiThemeVars.euiBorderRadius};
background: red;
border-radius: ${euiTheme.border.radius};

> div:first-child {
color: ${euiThemeVars.euiColorPrimary};
padding: ${euiThemeVars.euiFormControlPadding};
color: ${euiTheme.colors.primary};
padding: ${euiTheme.size.m};
}
`}
borders={'all'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
* 2.0.
*/

import { EuiText, EuiToolTip } from '@elastic/eui';
import { EuiText, EuiToolTip, useEuiTheme } from '@elastic/eui';
import type { EuiSuperSelectOption } from '@elastic/eui';
import React from 'react';
import styled from '@emotion/styled';
import { isEmpty } from 'lodash/fp';
import { euiThemeVars } from '@kbn/ui-theme';
import { PromptResponse } from '@kbn/elastic-assistant-common';
import { css } from '@emotion/react';
import { EMPTY_PROMPT } from './translations';

const Strong = styled.strong`
margin-right: ${euiThemeVars.euiSizeS};
margin-right: ${(props) => props.theme.euiTheme.size.s};
`;

interface GetOptionFromPromptProps extends PromptResponse {
Expand All @@ -25,23 +24,28 @@ interface GetOptionFromPromptProps extends PromptResponse {
name: string;
}

export const getOptionFromPrompt = ({
content,
id,
name,
}: GetOptionFromPromptProps): EuiSuperSelectOption<string> => ({
value: id,
inputDisplay: (
const InputDisplay = ({ name }: { name: string }) => {
const { euiTheme } = useEuiTheme();

return (
<span
data-test-subj="systemPromptText"
// @ts-ignore
css={css`
color: ${euiThemeVars.euiColorDarkestShade};
color: ${euiTheme.colors.darkestShade};
`}
>
{name}
</span>
),
);
};

export const getOptionFromPrompt = ({
content,
id,
name,
}: GetOptionFromPromptProps): EuiSuperSelectOption<string> => ({
value: id,
inputDisplay: <InputDisplay name={name} />,
dropdownDisplay: (
<>
<Strong data-test-subj={`systemPrompt-${name}`}>{name}</Strong>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
EuiFormRow,
EuiSuperSelect,
EuiToolTip,
useEuiTheme,
} from '@elastic/eui';
import React, { useCallback, useMemo, useState } from 'react';

import { euiThemeVars } from '@kbn/ui-theme';
import {
PromptResponse,
PromptTypeEnum,
Expand Down Expand Up @@ -56,6 +56,7 @@ const SelectSystemPromptComponent: React.FC<Props> = ({
selectedPrompt,
setIsSettingsModalVisible,
}) => {
const { euiTheme } = useEuiTheme();
const { setSelectedSettingsTab } = useAssistantContext();
const allSystemPrompts = useMemo(
() => allPrompts.filter((p) => p.promptType === PromptTypeEnum.system),
Expand Down Expand Up @@ -128,7 +129,7 @@ const SelectSystemPromptComponent: React.FC<Props> = ({
<EuiSuperSelect
// Limits popover z-index to prevent it from getting too high and covering tooltips.
// If the z-index is not defined, when a popover is opened, it sets the target z-index + 2000
popoverProps={{ zIndex: euiThemeVars.euiZLevel8 }}
popoverProps={{ zIndex: euiTheme.levels.modal as number }}
compressed={compressed}
data-test-subj={TEST_IDS.PROMPT_SUPERSELECT}
fullWidth
Expand Down Expand Up @@ -168,10 +169,10 @@ const SelectSystemPromptComponent: React.FC<Props> = ({
inline-size: 16px;
block-size: 16px;
border-radius: 16px;
background: ${euiThemeVars.euiColorMediumShade};
background: ${euiTheme.colors.backgroundBaseFormsControlDisabled};

:hover:not(:disabled) {
background: ${euiThemeVars.euiColorMediumShade};
background: ${euiTheme.colors.backgroundBaseFormsControlDisabled};
transform: none;
}

Expand Down
Loading