Skip to content

Commit

Permalink
Allow custom classes for authoring header (#885)
Browse files Browse the repository at this point in the history
* Allow custom classes for authoring header

* Fix lint

* 3.1.25
  • Loading branch information
thecalcc authored Oct 29, 2024
1 parent 8bcb31b commit 12acd35
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
18 changes: 11 additions & 7 deletions app-typescript/components/Layouts/AuthoringInnerHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as React from 'react';
import classNames from 'classnames';
import { Icon } from '../Icon';
import {Icon} from '../Icon';

interface IProps {
children?: React.ReactNode;
collapsed?: boolean;
headerPadding?: 'small' | 'medium' | 'large';
headerStyles?: string;
}
interface IState {
collapsed: boolean;
Expand All @@ -21,17 +21,21 @@ export class AuthoringInnerHeader extends React.PureComponent<IProps, IState> {
}

render() {
let classes = classNames('sd-editor-content__authoring-header', {
'authoring-header--collapsed': this.state.collapsed,
[`authoring-header--padding-${this.props.headerPadding}`]: this.props.headerPadding,
});
const classes = classNames(
'sd-editor-content__authoring-header',
{
'authoring-header--collapsed': this.state.collapsed,
[`${this.props.headerStyles}`]: this.props.headerStyles,
},
);

return (
<header className={classes}>
<div className="authoring-header__holder">
{this.props.children}
</div>
<button className="authoring-header__toggle"
onClick={() => this.setState({ collapsed: !this.state.collapsed })}>
onClick={() => this.setState({collapsed: !this.state.collapsed})}>
<Icon name="chevron-up-thin" />
</button>
</header>
Expand Down
9 changes: 5 additions & 4 deletions app-typescript/components/Layouts/AuthoringMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ interface IProps {
toolBar?: React.ReactNode;
authoringMain?: React.ReactNode;
authoringHeader?: React.ReactNode;
headerStyles?: string;
authoringBookmarks?: React.ReactNode;
headerCollapsed?: boolean;
headerPadding?: 'small' | 'medium' | 'large';
toolbarCustom?: boolean;
noPaddingForContent?: boolean;
}
Expand All @@ -33,10 +33,11 @@ export class AuthoringMain extends React.PureComponent<IProps> {
<AuthoringMainContent>
{this.props.authoringHeader && (
<AuthoringInnerHeader
headerPadding={this.props.headerPadding}
collapsed={this.props.headerCollapsed}>
headerStyles={this.props.headerStyles}
collapsed={this.props.headerCollapsed}
>
{this.props.authoringHeader}
</AuthoringInnerHeader>
</AuthoringInnerHeader>
)}
{this.props.authoringBookmarks && (
<AuthorinInnerSideBar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class EditorTest extends React.Component<IProps, IState> {
)}
main={(
<Layout.AuthoringMain
headerPadding='medium'
headerStyles='authoring-header--padding-medium'
toolBar={(
<React.Fragment>
<div className="sd-editor-toolbar__content">
Expand Down
2 changes: 1 addition & 1 deletion examples/pages/playgrounds/react-playgrounds/Multiedit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class Editor extends React.Component<{}, IEditor> {
)}
main={(
<Layout.AuthoringMain
headerPadding='medium'
headerStyles='authoring-header--padding-medium'
toolBar={(
<React.Fragment>
<div className="sd-editor-toolbar__content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class RundownEditor extends React.Component<IProps, IState> {
<Layout.HeaderPanel>
<SubNav>
<Tooltip text={this.state.isExpanded ? "Revert Authoring" : "Expand Authoring"} flow='right' appendToBody={true}>
<button
<button
className={`expand-button ${this.state.isExpanded ? "expand-button--expanded" : ""}`}
onClick={this.toggleExpand}
>
Expand Down Expand Up @@ -175,7 +175,7 @@ export class RundownEditor extends React.Component<IProps, IState> {

<Layout.MainPanel padding='none'>
<Layout.AuthoringMain
headerPadding='medium'
headerStyles='authoring-header--padding-medium'
toolBar={(
<React.Fragment>
<div className="sd-editor-toolbar__content">
Expand Down Expand Up @@ -341,7 +341,7 @@ export class RundownEditor extends React.Component<IProps, IState> {
<Layout.AuthoringFrame
main={
<Layout.AuthoringMain
headerPadding='medium'
headerStyles='authoring-header--padding-medium'
toolbarCustom={true}
headerCollapsed={true}
toolBar={(
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superdesk-ui-framework",
"version": "3.1.24",
"version": "3.1.25",
"license": "AGPL-3.0",
"repository": {
"type": "git",
Expand Down

0 comments on commit 12acd35

Please sign in to comment.