Skip to content

Commit 0520286

Browse files
authored
Merge pull request #56 from Ruchika30/add-optional-emojis
feat: added optional title prop
2 parents e5f08f4 + 0b844bf commit 0520286

8 files changed

+27
-5
lines changed

src/components/ContributingSection.test.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ describe("ContributingSection", () => {
88
expect(await render(<ContributingSection />)).toContain(
99
"## 🖋️ Contributing\n"
1010
);
11+
expect(
12+
await render(<ContributingSection title="Contributing" />)
13+
).toContain("## Contributing\n");
1114
});
1215

1316
it("renders sentence with a link to the contributing file", async () => {

src/components/ContributingSection.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ import MD, { Fragment, Heading, LineBreak, Link, Text } from "jsx-md";
55
/** @internal */
66
interface Props {
77
contributingFilePath?: string;
8+
title?: string;
89
}
9-
1010
/** Displays a contributing section based on optional contributing file path. */
1111
export const ContributingSection: Component<Props> = ({
1212
contributingFilePath = "./CONTRIBUTING.md",
13+
title = "🖋️ Contributing",
1314
}: Props) => {
1415
return (
1516
<Fragment>
16-
<Heading level={2}>🖋️ Contributing</Heading>
17+
<Heading level={2}>{title}</Heading>
1718
<Text>
1819
If you are interested in contributing to this repository, please read up
1920
on the details in our

src/components/ExamplesFromPkg.test.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ describe("ExamplesFromPkg", () => {
2929
expect(await render(<ExamplesFromPkg pkg={pkg} />)).toContain(
3030
"## 🔬 Examples\n"
3131
);
32+
33+
expect(
34+
await render(<ExamplesFromPkg pkg={pkg} title="Examples" />)
35+
).toContain("## Examples\n");
3236
});
3337

3438
it("renders the example.json file as an ExampleFile", async () => {

src/components/ExamplesFromPkg.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface Props {
1111
encoding?: BufferEncoding;
1212
replacePackageImportsWithPackageName?: boolean;
1313
pkg: PackageJSON;
14+
title?: string;
1415
}
1516

1617
/** Show all files from the example directory defined in package.json.² */
@@ -21,6 +22,7 @@ export const ExamplesFromPkg: Component<Props> = awaitComponent(
2122
encoding = "utf8",
2223
/** Whether to replace all imports from '..' with imports from 'package-name' */
2324
replacePackageImportsWithPackageName = true,
25+
title = "🔬 Examples",
2426
}) => {
2527
const examplesFolder = pkg.directories?.example;
2628
if (examplesFolder === undefined) {
@@ -48,7 +50,7 @@ export const ExamplesFromPkg: Component<Props> = awaitComponent(
4850

4951
return (
5052
<Fragment>
51-
<Heading level={2}>🔬 Examples</Heading>
53+
<Heading level={2}>{title}</Heading>
5254
{examples
5355
.sort(({ fileName: fileNameA }, { fileName: fileNameB }) =>
5456
fileNameA.localeCompare(fileNameB, "en", { sensitivity: "base" })

src/components/HomepageFromPkg.test.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ describe("HomepageFromPkg", () => {
1515
homepage: "https://dbartholomae.github.io/jsx-readme",
1616
name: "test-package",
1717
};
18+
expect(
19+
await render(<HomepageFromPkg pkg={pkg} title="Homepage" />)
20+
).toContain("## Homepage\n");
21+
1822
expect(await render(<HomepageFromPkg pkg={pkg} />)).toContain(
1923
"## 🏠 Homepage\n"
2024
);

src/components/HomepageFromPkg.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@ import type { PackageJSON } from "../PackageJSON";
66
/** @internal */
77
interface Props {
88
pkg: Readonly<PackageJSON>;
9+
title?: string;
910
}
1011

1112
/** Display a section linking to the homepage defined in package.json */
1213
export const HomepageFromPkg: Component<Readonly<Props>> = ({
1314
pkg: { homepage },
15+
title = "🏠 Homepage",
1416
}) => {
1517
if (homepage === undefined) {
1618
return null;
1719
}
1820

1921
return (
2022
<Fragment>
21-
<Heading level={2}>🏠 Homepage</Heading>
23+
<Heading level={2}>{title}</Heading>
2224
You can find more about this on <Link to={homepage}>{homepage}</Link>.
2325
<LineBreak />
2426
<LineBreak />

src/components/LicenseFromPkg.test.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ describe("LicenseFromPkg", () => {
1515
name: "test-package",
1616
license: "MIT",
1717
};
18+
expect(
19+
await render(<LicenseFromPkg pkg={pkg} title="License" />)
20+
).toContain("## License\n");
21+
1822
expect(await render(<LicenseFromPkg pkg={pkg} />)).toContain(
1923
"## 📜 License\n"
2024
);

src/components/LicenseFromPkg.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ import type { PackageJSON } from "../PackageJSON";
77
interface Props {
88
licenseFilePath?: string;
99
pkg: Readonly<PackageJSON>;
10+
title?: string;
1011
}
1112

1213
/** Display a section indicating the license defined in package.json */
1314
export const LicenseFromPkg: Component<Readonly<Props>> = ({
1415
pkg: { license },
1516
licenseFilePath = "./LICENSE",
17+
title = "📜 License",
1618
}) => {
1719
if (license === undefined) {
1820
return null;
1921
}
2022

2123
return (
2224
<Fragment>
23-
<Heading level={2}>📜 License</Heading>
25+
<Heading level={2}>{title}</Heading>
2426
{license}. See <Link to={licenseFilePath}>LICENSE file</Link> for details.
2527
<LineBreak />
2628
<LineBreak />

0 commit comments

Comments
 (0)