committed by
Bastian
parent
e0113c446d
commit
dc84d19236
14
README.md
14
README.md
@@ -110,6 +110,20 @@ To change the logo, create a public folder in your application and put your `log
|
|||||||
|
|
||||||
For reference have a look at [public/logo.svg](./public/logo.svg).
|
For reference have a look at [public/logo.svg](./public/logo.svg).
|
||||||
|
|
||||||
|
### Change the logo
|
||||||
|
By default the Date format used in the app is `"MMMM YYYY"`.
|
||||||
|
You can change this by editing the config file as shown below.
|
||||||
|
Please be sure you are entering a valid [moment.js format string](https://momentjs.com/docs/#/displaying/format).
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
"dateFormat": "MMMM YYYY"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
For reference have a look at [public/logo.svg](./public/logo.svg).
|
||||||
|
|
||||||
### Change the rings and quadrants config
|
### Change the rings and quadrants config
|
||||||
To change the default rings and quadrants of the radar, you can place a custom `config.json` file within the `public` folder.
|
To change the default rings and quadrants of the radar, you can place a custom `config.json` file within the `public` folder.
|
||||||
The `showEmptyRings` option can be enabled to display the header for a ring even when it contains no items (helpful to
|
The `showEmptyRings` option can be enabled to display the header for a ring even when it contains no items (helpful to
|
||||||
|
|||||||
@@ -64,5 +64,6 @@
|
|||||||
"arcWidth": 2
|
"arcWidth": 2
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
"dateFormat": "MMMM YYYY"
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,18 @@ import Badge from "../Badge/Badge";
|
|||||||
import { formatRelease } from "../../date";
|
import { formatRelease } from "../../date";
|
||||||
import { Revision } from "../../model";
|
import { Revision } from "../../model";
|
||||||
|
|
||||||
export default function ItemRevision({ revision }: { revision: Revision }) {
|
export default function ItemRevision({
|
||||||
|
revision,
|
||||||
|
dateFormat,
|
||||||
|
}: {
|
||||||
|
revision: Revision;
|
||||||
|
dateFormat?: string
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="item-revision">
|
<div className="item-revision">
|
||||||
<div>
|
<div>
|
||||||
<Badge type={revision.ring}>
|
<Badge type={revision.ring}>
|
||||||
{revision.ring} | {formatRelease(revision.release)}
|
{revision.ring} | {formatRelease(revision.release, dateFormat)}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
import React from "react";
|
|
||||||
import HeadlineGroup from "../HeadlineGroup/HeadlineGroup";
|
import HeadlineGroup from "../HeadlineGroup/HeadlineGroup";
|
||||||
import ItemRevision from "../ItemRevision/ItemRevision";
|
import ItemRevision from "../ItemRevision/ItemRevision";
|
||||||
import { Revision } from "../../model";
|
import { Revision } from "../../model";
|
||||||
import "./item-revisions.scss";
|
import "./item-revisions.scss";
|
||||||
import { useMessages } from "../../context/MessagesContext";
|
import { useMessages } from "../../context/MessagesContext";
|
||||||
|
|
||||||
export default function ItemRevisions({
|
export default function ItemRevisions({
|
||||||
revisions,
|
revisions,
|
||||||
|
dateFormat,
|
||||||
}: {
|
}: {
|
||||||
revisions: Revision[];
|
revisions: Revision[];
|
||||||
|
dateFormat?: string
|
||||||
}) {
|
}) {
|
||||||
const { revisionsText } = useMessages();
|
const { revisionsText } = useMessages();
|
||||||
return (
|
return (
|
||||||
@@ -17,7 +19,7 @@ export default function ItemRevisions({
|
|||||||
</HeadlineGroup>
|
</HeadlineGroup>
|
||||||
|
|
||||||
{revisions.map((revision) => (
|
{revisions.map((revision) => (
|
||||||
<ItemRevision key={revision.release} revision={revision} />
|
<ItemRevision key={revision.release} revision={revision} dateFormat={dateFormat} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export default function PageIndex({
|
|||||||
<QuadrantGrid items={featuredOnly(items)} config={config} />
|
<QuadrantGrid items={featuredOnly(items)} config={config} />
|
||||||
)}
|
)}
|
||||||
<div className="publish-date">
|
<div className="publish-date">
|
||||||
{publishedLabel} {formatRelease(newestRelease)}
|
{publishedLabel} {formatRelease(newestRelease, config.dateFormat)}
|
||||||
</div>
|
</div>
|
||||||
</Fadeable>
|
</Fadeable>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ const PageItem: React.FC<Props> = ({ pageName, items, config, leaving, onLeave }
|
|||||||
dangerouslySetInnerHTML={{ __html: item.body }}
|
dangerouslySetInnerHTML={{ __html: item.body }}
|
||||||
/>
|
/>
|
||||||
{item.revisions.length > 1 && (
|
{item.revisions.length > 1 && (
|
||||||
<ItemRevisions revisions={item.revisions.slice(1)} />
|
<ItemRevisions revisions={item.revisions.slice(1)} dateFormat={config.dateFormat} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export interface ConfigData {
|
|||||||
ringsAttributes: {radius: number, arcWidth: number}[]
|
ringsAttributes: {radius: number, arcWidth: number}[]
|
||||||
};
|
};
|
||||||
homepageContent: HomepageOption;
|
homepageContent: HomepageOption;
|
||||||
|
dateFormat?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const radarName =
|
export const radarName =
|
||||||
|
|||||||
11
src/date.test.tsx
Normal file
11
src/date.test.tsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import moment from "moment";
|
||||||
|
import { formatRelease } from "./date";
|
||||||
|
|
||||||
|
describe("formatRelease", () => {
|
||||||
|
it("should format a date object using default output format", () => {
|
||||||
|
expect(formatRelease(moment('2022-01-05'))).toEqual('January 2022')
|
||||||
|
});
|
||||||
|
it("should format a date object using a custom output format", () => {
|
||||||
|
expect(formatRelease(moment('2022-01-05'), 'DD.MM.YYYY')).toEqual('05.01.2022')
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -3,5 +3,5 @@ import moment from "moment";
|
|||||||
const isoDateToMoment = (isoDate: moment.MomentInput) =>
|
const isoDateToMoment = (isoDate: moment.MomentInput) =>
|
||||||
moment(isoDate, "YYYY-MM-DD");
|
moment(isoDate, "YYYY-MM-DD");
|
||||||
|
|
||||||
export const formatRelease = (isoDate: moment.MomentInput) =>
|
export const formatRelease = (isoDate: moment.MomentInput, format: string = "MMMM YYYY") =>
|
||||||
isoDateToMoment(isoDate).format("MMMM YYYY");
|
isoDateToMoment(isoDate).format(format);
|
||||||
|
|||||||
Reference in New Issue
Block a user