@ta-interaktiv/react-publication-info

Displays publication meta data (like publication and update date as well as version number).

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@ta-interaktiv/react-publication-info
2.0.04 years ago7 years agoMinified + gzip package size for @ta-interaktiv/react-publication-info in KB

Readme

React Publication Info
Displays publication meta data (like publication and update date as well as version number).
npm version

API

Table of Contents

-   [Parameters](#parameters)
-   [Examples](#examples)
-   [Parameters](#parameters-1)
-   [Parameters](#parameters-2)
-   [Examples](#examples-1)
-   [Parameters](#parameters-3)
-   [Examples](#examples-2)

NameValueItem

Generic key-value component.

Parameters

-   `props.name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** The name or key of the information.
-   `props.value` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** The value. If null or undefined, the component will not render.
-   `props.itemClassName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Class name(s) for the whole item. (optional, default `''`)
-   `props.nameClassName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Class names(s) for the key  part. (optional, default `''`)
-   `props.valueClassName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Class names(s) for the value part. (optional, default `''`)

Examples

import { NameValueItem }from '@ta-interaktiv/react-publication-info'

function Component(props) {
  return(
    <NameValueItem
      name='Version'
      value='1.0.0'
      itemClassName='ui label'
      valueClassName='detail'
    />
  )
}

// returns <span className="name-value-item ui label">
//           <span className="name ">Version</span>
//           <span className="value detail">1.0.0</span>
//         </span>

Returns (React.Element<any> | null)

PublicationInfo

Show all information regarding a publication: when it has been first published, when it was updated, and what version it is.

Parameters

-   `props.publicationDate` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Unix timestamp when the project has been first published (optional, default `window.project.publicationDate`)
-   `props.changeDate` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Unix timestamp when the project has been last updated. (optional, default `window.project.changeDate`)
-   `props.version` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Version number of the project (optional, default `window.project.version`)
-   `props.className` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** CSS class name of the whole object. (optional, default `''`)
-   `props.itemClassName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** CSS class names for the individual items. (optional, default `''`)
-   `props.nameClassName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** CSS class names for the key/name of the individual items. (optional, default `''`)
-   `props.valueClassName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** CSS class names for the value of the individual items. (optional, default `''`)
Returns React.Element<any>

TimestampFormatter

  • See: NameValueItem for additional className parameters to be passed into this component.

Provides a formatted timestamp, with an optional prefix. Modeled after the common article suffix on tagesanzeiger.ch articles, it will return something like "Erstellt: 25.07.2017, 11:47 Uhr" with the appropriate prefix.

Parameters

-   `props.timestamp` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** A UNIX timestamp, in seconds. If not provided, the element will not render.
-   `props.prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** A string that precedes the date, like "Erstellt:" or "Aktualisiert:"
-   `props.locale` **(`"de"` \| `"fr"`)** The locale to use to format the
    string. (optional, default `de`)

Examples

import { TimestampFormatter } from '@ta-interaktiv/react-publication-date'

function Component (props) {
  return (
    <TimestampFormatter prefix='Erstellt:' timestamp={1500986249} />
  )
}

Returns (Element<any> | null)

VersionFormatter

  • See: NameValueItem for additional className props that can be passed in.

Provides a formatted version, with an optional prefix.

Parameters

-   `props.version` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** A semantic version string. If not provided, the element will not render.
-   `props.prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** A string that precedes the version. (optional, default `Version`)

Examples

import { VersionFormatter } from '@ta-interaktiv/react-publication-date'

function Component (props) {
  return (
    <VersionFormatter version='1.0.0' />
  )
}

Returns
(React.Element<any> | null)

Contributing

Development

Code resides in /src. Test cases are provided using Storybook
. Add test cases in /stories/index.js, and run them with
yarn run storybook

They will appear on .
This repository follows the Standard JS style. To fix your code, run
yarn run fix

JavaScript Style Guide

Building & Releasing

Babel is used to provide ES5 compatible code. To compile run
yarn run dist

Changes should go into the changelog. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
Update the Readme with the current API using
yarn run docs