Skip to content

Commit

Permalink
Branding config structure change and renaming
Browse files Browse the repository at this point in the history
Change the branding related config to a map structure in the yml file.
Also rename the configs according to the official branding guidelines.
The full logo on the main page header will be called logo; the small
logo icon will be called mark.

Signed-off-by: Abby Hu <abigailhu2000@gmail.com>
  • Loading branch information
abbyhu2000 committed Sep 10, 2021
1 parent f401327 commit 5238060
Show file tree
Hide file tree
Showing 22 changed files with 355 additions and 133 deletions.
25 changes: 12 additions & 13 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,15 @@
# ]
#vis_type_timeline.graphiteBlockedIPs: []

# full version customized logo URL
# opensearchDashboards.branding.fullLogoUrl: ""

# smaller version customized logo URL
# opensearchDashboards.branding.logoUrl: ""

# customized loading logo URL
# opensearchDashboards.branding.loadingLogoUrl: ""

# custom application title
# opensearchDashboards.branding.title: ""


#opensearchDashboards.branding:
#logo:
#default: ""
#darkmode: ""
#mark:
#default: ""
#darkmode: ""
#loadingLogo:
#default: ""
#darkmode: ""
#favicon: ""
#title: ""
56 changes: 40 additions & 16 deletions src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,31 @@ import { CustomLogo } from './opensearch_dashboards_custom_logo';

describe('Custom Logo', () => {
it('Take in a normal full logo URL string', () => {
const branding = { fullLogoUrl: '/custom', title: 'title' };
const branding = {
logo: { default: '/' },
mark: {},
title: 'title',
};
const component = mountWithIntl(<CustomLogo {...branding} />);
expect(component).toMatchSnapshot();
});

it('Take in an invalid full logo URL string and a valid logo URL string', () => {
const branding = { logoUrl: '/custom', title: 'title' };
const branding = {
logo: {},
mark: { default: '/' },
title: 'title',
};
const component = mountWithIntl(<CustomLogo {...branding} />);
expect(component).toMatchSnapshot();
});

it('Take in invalid full logo URL and logo URL', () => {
const branding = { title: 'title' };
const branding = {
logo: {},
mark: {},
title: 'title',
};
const component = mountWithIntl(<CustomLogo {...branding} />);
expect(component).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,38 @@ import { OpenSearchDashboardsLogoDarkMode } from './opensearch_dashboards_logo_d
* @param {string} title - custom title for the application
*/
export interface CustomLogoType {
fullLogoUrl?: string;
logoUrl?: string;
title: string;
logo: {
default?: string;
darkmode?: string;
};
mark: {
default?: string;
darkmode?: string;
};
title?: string;
}
/**
*
* @param {CustomLogoType} - branding object consist of fullLogoUrl, logoUrl and title
* @param {CustomLogoType} - branding object consist of logo, mark and title
* @returns A image component which is going to be rendered on the main page header bar.
* If fullLogoUrl is valid, the full logo by fullLogoUrl config will be rendered;
* if not, the logo icon by logoUrl config will be rendered; if both are not found,
* If logo default is valid, the full logo by logo default config will be rendered;
* if not, the logo icon by mark default config will be rendered; if both are not found,
* the default opensearch logo will be rendered.
*/
export const CustomLogo = ({ ...branding }: CustomLogoType) => {
const headerLogoUrl = !branding.fullLogoUrl ? branding.logoUrl : branding.fullLogoUrl;
return !branding.fullLogoUrl && !branding.logoUrl ? (
const headerLogoUrl = !branding.logo.default ? branding.mark.default : branding.logo.default;
return !branding.logo.default && !branding.mark.default ? (
OpenSearchDashboardsLogoDarkMode()
) : (
<img
data-test-subj="customLogo"
data-test-image-url={headerLogoUrl}
src={headerLogoUrl}
alt={branding.title + ' logo'}
loading="lazy"
className="logoImage"
/>
<div className="logoContainer">
<img
data-test-subj="customLogo"
data-test-image-url={headerLogoUrl}
src={headerLogoUrl}
alt={branding.title + ' logo'}
loading="lazy"
className="logoImage"
/>
</div>
);
};
6 changes: 5 additions & 1 deletion src/core/public/chrome/ui/header/header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ function mockProps() {
isLocked$: new BehaviorSubject(false),
loadingCount$: new BehaviorSubject(0),
onIsLockedUpdate: () => {},
branding: { fullLogoUrl: '/', logoUrl: '/', title: 'OpenSearch Dashboards' },
branding: {
logo: { default: '/' },
mark: { default: '/' },
title: 'OpenSearch Dashboards',
},
};
}

Expand Down
12 changes: 11 additions & 1 deletion src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,17 @@ export interface HeaderProps {
isLocked$: Observable<boolean>;
loadingCount$: ReturnType<HttpStart['getLoadingCount$']>;
onIsLockedUpdate: OnIsLockedUpdate;
branding: { fullLogoUrl?: string; logoUrl?: string; title: string };
branding: {
logo: {
default?: string;
darkmode?: string;
};
mark: {
default?: string;
darkmode?: string;
};
title?: string;
};
}

export function Header({
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/chrome/ui/header/header_logo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
padding: 3px 3px 3px 10px;
}

.logoImage{
.logoImage {
height: 100%;
max-width: 100%;
}
16 changes: 10 additions & 6 deletions src/core/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,11 @@ export interface CoreSetup<TPluginsStart extends object = object, TStart = unkno
injectedMetadata: {
getInjectedVar: (name: string, defaultValue?: any) => unknown;
getBranding: () => {
fullLogoUrl?: string;
logoUrl?: string;
title: string;
mark: {
default?: string;
darkmode?: string;
};
title?: string;
};
};
/** {@link StartServicesAccessor} */
Expand Down Expand Up @@ -297,9 +299,11 @@ export interface CoreStart {
injectedMetadata: {
getInjectedVar: (name: string, defaultValue?: any) => unknown;
getBranding: () => {
fullLogoUrl?: string;
logoUrl?: string;
title: string;
mark: {
default?: string;
darkmode?: string;
};
title?: string;
};
};
}
Expand Down
Loading

0 comments on commit 5238060

Please sign in to comment.