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

Enhancements for keyboard shortcuts overview page (CMEM-4787) #120

Merged
merged 4 commits into from
Aug 28, 2023
Merged
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

### Added

- `<PropertyName />`
- provide `labelProps` to configure the automatically injected `Label` element when `PropertyName` is only a string

### Fixed

- `<Spacing />`
- allow other `div` attributes, e.g. `style`

## [23.2.0] - 2023-07-14

### Added
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/canonicalIconNames.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type ValidIconName =
| "application-useraccount"
| "application-vocabularies"
| "application-warning"
| "application-hotkeys"
| "artefact-commit"
| "artefact-customtask"
| "artefact-dataset"
Expand Down Expand Up @@ -162,6 +163,7 @@ const canonicalIconNames: Record<ValidIconName, CarbonIconType> = {
"application-useraccount": icons.UserAvatar,
"application-vocabularies": icons.Catalog,
"application-warning": icons.WarningAlt,
"application-hotkeys": icons.Keyboard,

"artefact-commit": icons.Commit,
"artefact-customtask": icons.Script,
Expand Down
19 changes: 15 additions & 4 deletions src/components/PropertyValuePair/PropertyName.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
import React from "react";

import { CLASSPREFIX as eccgui } from "../../configuration/constants";
import Label from "../Label/Label";
import Label, { LabelProps } from "../Label/Label";

export interface PropertyNameProps extends React.HTMLAttributes<HTMLElement> {
/**
* Increase or decrease the width used for the property name.
*/
size?: "small" | "medium" | "large";
/**
* Additional label properties, e.g. `tooltip`.
* It is only used if the `PropertyName` has simple text input.
*/
labelProps?: LabelProps;
}

export const PropertyName = ({ className = "", size, children, ...otherProps }: PropertyNameProps) => {
export const PropertyName = ({ className = "", size, children, labelProps, ...otherDtProps }: PropertyNameProps) => {
return (
<dt
className={
`${eccgui}-propertyvalue__property` +
(size ? ` ${eccgui}-propertyvalue__property--${size}` : "") +
(className ? " " + className : "")
}
{...otherProps}
{...otherDtProps}
>
<div>{typeof children === "string" ? <Label text={children} isLayoutForElement="span" /> : children}</div>
<div>
{typeof children === "string" ? (
<Label text={children} isLayoutForElement="span" {...labelProps} />
) : (
children
)}
</div>
</dt>
);
};
Expand Down
20 changes: 12 additions & 8 deletions src/components/Separation/Spacing.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
import React from "react";

import { CLASSPREFIX as eccgui } from "../../configuration/constants";

export interface SpacingProps {
export interface SpacingProps extends React.HTMLAttributes<HTMLDivElement> {
/**
* Set the amount of white space that separates two elements.
*/
size?: "tiny" | "small" | "medium" | "large" | "xlarge"
size?: "tiny" | "small" | "medium" | "large" | "xlarge";
/**
* If set then is a ruler displayed in the middle of the spacing area.
* The direction of the ruler is used from the spacing.
*/
hasDivider?: boolean
hasDivider?: boolean;
/**
* If set then the spacing separates two elements on the horizontal axis.
* The spacing area then is created on a vertical axis.
*/
vertical?: boolean
vertical?: boolean;
}

/**
* Adds horizontal or vertical space between neighbouring elements.
* It also can add a visual ruler inside.
*/
export const Spacing = ({ size = "medium", hasDivider = false, vertical = false }: SpacingProps) => {
export const Spacing = ({ size = "medium", hasDivider = false, vertical = false, ...otherDivProps }: SpacingProps) => {
const direction = vertical ? "vertical" : "horizontal";
return (
<div
className={
`${eccgui}-separation__spacing-` + direction +
` ${eccgui}-separation__spacing--` + size +
`${eccgui}-separation__spacing-` +
direction +
` ${eccgui}-separation__spacing--` +
size +
(hasDivider ? ` ${eccgui}-separation__spacing--hasdivider` : "")
}
{...otherDivProps}
/>
);
}
};

export default Spacing;
Loading