Skip to content

Commit

Permalink
fix(react-components): Change help panel again and bump to 0.73.9 (#4941
Browse files Browse the repository at this point in the history
)

* fix(react-components): Change help panel again

* chore: bump react-components to 0.73.9

* chore: update help button with placement option

* chore: reorder ??

* chore: redefine placement option

* chore: extend type
  • Loading branch information
haakonflatval-cognite authored Dec 12, 2024
1 parent c7a7033 commit 6e9251b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion react-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cognite/reveal-react-components",
"version": "0.73.8",
"version": "0.73.9",
"exports": {
".": {
"import": "./dist/index.js",
Expand Down
6 changes: 5 additions & 1 deletion react-components/src/components/Architecture/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

export type ButtonType = 'ghost' | 'ghost-destructive' | 'primary';

export type PlacementType = 'top' | 'right' | 'left' | 'bottom';
type Side = 'top' | 'right' | 'bottom' | 'left';

type Alignment = 'start' | 'end';

export type PlacementType = Side | `${Side}-${Alignment}`;

export type FlexDirection = 'row' | 'column';
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const KeyboardNavigationInstructionGrid = styled.div`

export const ArrowKeyboardNavigationInstructionGrid = styled.div`
display: grid;
grid-template-columns: 2fr 1fr 1.5fr;
grid-template-columns: 1fr 1fr 1fr;
gap: 8px;
padding-left: 12px;
width: fit-content;
Expand Down
18 changes: 12 additions & 6 deletions react-components/src/components/RevealToolbar/HelpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import { MouseNavigation } from './Help/MouseNavigation';
import { TouchNavigation } from './Help/TouchNavigation';
import { KeyboardNavigation } from './Help/KeyboardNavigation';
import { useTranslation } from '../i18n/I18n';
import { type PlacementType } from '../Architecture';

export type HelpButtonProps = {
fallbackLanguage?: string;
placement?: PlacementType;
};

export const HelpButton = ({ fallbackLanguage }: HelpButtonProps): ReactElement => {
export const HelpButton = ({ fallbackLanguage, placement }: HelpButtonProps): ReactElement => {
const { t } = useTranslation(fallbackLanguage);
const [helpActive, setHelpActive] = useState<boolean>(false);

Expand All @@ -26,15 +28,18 @@ export const HelpButton = ({ fallbackLanguage }: HelpButtonProps): ReactElement
onClickOutside={() => {
setHelpActive(false);
}}
placement="right"
placement={placement ?? 'right'}
content={
<StyledContainer>
<MouseNavigation fallbackLanguage={fallbackLanguage} />
<KeyboardNavigation fallbackLanguage={fallbackLanguage} />
<TouchNavigation fallbackLanguage={fallbackLanguage} />
</StyledContainer>
}>
<CogsTooltip content={t({ key: 'HELP_TOOLTIP' })} placement="right" appendTo={document.body}>
<CogsTooltip
content={t({ key: 'HELP_TOOLTIP' })}
placement={'right'}
appendTo={document.body}>
<Button
type="ghost"
icon={<HelpIcon />}
Expand All @@ -53,9 +58,10 @@ const StyledContainer = styled.div`
background-color: #516efa;
border-radius: 4px;
display: flex;
flex-direction: row;
flex-direction: column;
gap: 24px;
padding: 16px;
// Width of help panel content sums to 1000. Would probably be better if it scaled to screen size
max-width: 1000px;
width: fit-content;
max-height: 20vw;
overflow-y: auto;
`;

0 comments on commit 6e9251b

Please sign in to comment.