Skip to content
Open
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
31 changes: 15 additions & 16 deletions build-tools/utils/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@ function writeFile(filepath, content) {
}

function listPublicItems(baseDir) {
return fs
.readdirSync(baseDir)
.filter(
elem =>
!elem.startsWith('__') &&
!elem.startsWith('.') &&
elem !== 'internal' &&
elem !== 'index.tsx' &&
elem !== 'index.ts' &&
elem !== 'interfaces.ts' &&
elem !== 'test-utils' &&
elem !== 'i18n' &&
elem !== 'theming' &&
elem !== 'plugins' &&
elem !== 'contexts'
);
return fs.readdirSync(baseDir).filter(
elem =>
!elem.startsWith('__') &&
!elem.startsWith('.') &&
elem !== 'internal' &&
elem !== 'navigation-bar' && // in development, not yet public
elem !== 'index.tsx' &&
elem !== 'index.ts' &&
elem !== 'interfaces.ts' &&
elem !== 'test-utils' &&
elem !== 'i18n' &&
elem !== 'theming' &&
elem !== 'plugins' &&
elem !== 'contexts'
);
}

module.exports = { writeFile, listPublicItems };
1 change: 1 addition & 0 deletions build-tools/utils/pluralize.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const pluralizationMap = {
Modal: 'Modals',
Multiselect: 'Multiselects',
NavigableGroup: 'NavigableGroups',
NavigationBar: 'NavigationBars',
Pagination: 'Paginations',
AppLayoutToolbar: 'AppLayoutToolbars',
PanelLayout: 'PanelLayouts',
Expand Down
27 changes: 13 additions & 14 deletions src/__tests__/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ const componentsDir = path.resolve(__dirname, '../../lib/components');
const designTokensDir = path.resolve(__dirname, '../../lib/design-tokens');

export function getAllComponents(): string[] {
return fs
.readdirSync(componentsDir)
.filter(
name =>
name !== 'internal' &&
name !== 'test-utils' &&
name !== 'theming' &&
name !== 'contexts' &&
name !== 'plugins' &&
name !== 'i18n' &&
!name.includes('.') &&
!name.includes('LICENSE') &&
!name.includes('NOTICE')
);
return fs.readdirSync(componentsDir).filter(
name =>
name !== 'internal' &&
name !== 'navigation-bar' && // in development, not yet public
name !== 'test-utils' &&
name !== 'theming' &&
name !== 'contexts' &&
name !== 'plugins' &&
name !== 'i18n' &&
!name.includes('.') &&
!name.includes('LICENSE') &&
!name.includes('NOTICE')
);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions src/navigation-bar/__tests__/navigation-bar.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';
import { render } from '@testing-library/react';

import NavigationBar from '../../../lib/components/navigation-bar';

describe('NavigationBar', () => {
test('renders content', () => {
const { container } = render(<NavigationBar content={<span>Hello</span>} />);
expect(container.querySelector('nav')).toHaveTextContent('Hello');
});
});
19 changes: 19 additions & 0 deletions src/navigation-bar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
'use client';
import React from 'react';

import useBaseComponent from '../internal/hooks/use-base-component';
import { applyDisplayName } from '../internal/utils/apply-display-name';
import { getExternalProps } from '../internal/utils/external-props';
import { NavigationBarProps } from './interfaces';
import InternalNavigationBar from './internal';

export { NavigationBarProps };

export default function NavigationBar(props: NavigationBarProps) {
const baseComponentProps = useBaseComponent('NavigationBar');
return <InternalNavigationBar {...getExternalProps(props)} {...baseComponentProps} />;
}

applyDisplayName(NavigationBar, 'NavigationBar');
17 changes: 17 additions & 0 deletions src/navigation-bar/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { ReactNode } from 'react';

import { BaseComponentProps } from '../internal/base-component';

export interface NavigationBarProps extends BaseComponentProps {
/**
* Content of the navigation bar.
*/
content?: ReactNode;

/**
* Accessible label for the navigation landmark.
*/
ariaLabel?: string;
}
32 changes: 32 additions & 0 deletions src/navigation-bar/internal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';
import clsx from 'clsx';

import { getBaseProps } from '../internal/base-component';
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
import { NavigationBarProps } from './interfaces';

import styles from './styles.css.js';

type InternalNavigationBarProps = NavigationBarProps & InternalBaseComponentProps;

export default function InternalNavigationBar({
content,
ariaLabel,
__internalRootRef,
...restProps
}: InternalNavigationBarProps) {
const baseProps = getBaseProps(restProps);

return (
<nav
{...baseProps}
ref={__internalRootRef}
aria-label={ariaLabel}
className={clsx(baseProps.className, styles.root)}
>
{content}
</nav>
);
}
13 changes: 13 additions & 0 deletions src/navigation-bar/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

@use '../internal/styles' as styles;

.root {
@include styles.styles-reset;
display: flex;
align-items: center;
box-sizing: border-box;
}
Loading