Skip to content

Commit c9884cc

Browse files
committed
Close navbar dropdown on click
1 parent 98a2ca9 commit c9884cc

File tree

2 files changed

+40
-11
lines changed

2 files changed

+40
-11
lines changed

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ The file structure for each component should look like the following:
5454
- `MyComponent.css`
5555
- `MyComponent.test.tsx`
5656

57+
### TypeScript and JSX
58+
59+
This repo is configured to use TypeScript and JSX. Any file that uses TypeScript and JSX syntax (i.e. component files and any other files that include components) should use the `.tsx` extension.
60+
5761
### Testing Components During Development
5862

5963
To see how your component looks and behaves while you are developing it, you have a few different options. When you start the app locally, the main entry point that determines what is rendered is in `src/app.tsx`. Because this is a component library and not a fully integrated app, the `app.tsx` file exists solely as a testing sandbox. A simple routing structure has been setup to test out different kinds of pages in a react-only environment. These test pages live in the `src/pages` directory. When testing a new component, you can use it inside of one of the existing pages or you can create a new page. There is also the `Sandbox` page within the `pages` directory that is intended to be cleared out any time and used to test new discrete components.
@@ -66,9 +70,9 @@ By convention, almost all components are given a top-level class which is the na
6670

6771
The components in this library are intended to be used with the Bulma CSS Framework. For that reason, many bulma classes and component patterns are utilized within the components.
6872

69-
### Test ID's
73+
### Test IDs
7074

71-
Also by convention, almost all components are given a "test id" via the attribute `data-testid`. In some cases, a component may have multiple elements with test id's. These id's make it easier to select the components and their testable parts within the unit tests.
75+
Also by convention, almost all components are given a test ID via the attribute `data-testid`. In some cases, a component may have multiple elements with test IDs. These IDs make it easier to select the components and their testable parts within the unit tests.
7276

7377
### Component Utils
7478

@@ -86,6 +90,28 @@ Most components also have their own props interface defined. Note that this inte
8690

8791
Any component that you want to be usable when this library is imported as a third-party node module must be added to the exports list in `src/index.ts`.
8892

93+
## Unit Tests
94+
95+
This repo uses [jest](https://jestjs.io/) and [react testing library](https://testing-library.com/) to write and run unit tests. Any file in the `src` directory with the `.test.tsx` or `.spec.tsx` extension will be detected as a runnable test.
96+
97+
Run all the unit tests:
98+
99+
```
100+
npm run test
101+
```
102+
103+
Run a specific test suite:
104+
105+
```
106+
npm run test MaterialsInput
107+
```
108+
109+
The jest configuration can be found in `jest.config.js`
110+
111+
### Mocks
112+
113+
To test the fetching behavior of the `SearchUI` components, there is a `mocks` directory which sets up a Mock Service Worker using the `msw` package. See more [here](https://mswjs.io/docs/getting-started/integrate/node).
114+
89115
## Deploying to npm
90116

91117
### Automated Pre-releases
@@ -104,7 +130,7 @@ Use `npm publish` to push to npm
104130

105131
### Automated Minor Release (un-tested)
106132

107-
Run `npm version minor -m "Upgrade to %s"` to add a tag. Once the tag is pushed, an action will
133+
Run `npm version minor -m "Upgrade to %s"` to add a tag. Once the tag is pushed, an action willg
108134
build the components and push the package to build to npm
109135

110136
## Developing with dash-mp-components
@@ -147,3 +173,5 @@ npm deploy-storybook
147173
```
148174

149175
### Build Tools
176+
177+
This repo uses Parcel to build and run the app locally and Rollup to publish the app. Parcel does not have a config file, but it does use Babel to transpile the code for this repo. The babel configuration exists in `.babelrc` and `babel.config.js`. The Rollup configuration is defined in `rollup.config.js`.

src/components/navigation/NavbarDropdown/NavbarDropdown.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ export const NavbarDropdown: React.FC<Props> = (props) => {
6565
} else {
6666
/** Use a <Link> component for internal links */
6767
return (
68-
<Link
69-
key={i}
70-
href={item.href || ''}
71-
className={classNames('navbar-item', item.className)}
72-
// onClick={() => setIsActive(false)}
73-
>
74-
{item.label}
75-
</Link>
68+
<span onClick={() => setIsActive(false)}>
69+
<Link
70+
key={i}
71+
href={item.href || ''}
72+
className={classNames('navbar-item', item.className)}
73+
>
74+
{item.label}
75+
</Link>
76+
</span>
7677
);
7778
}
7879
})}

0 commit comments

Comments
 (0)