Skip to content

Commit af2b6dc

Browse files
committed
feat: implement the TextRenderer component
This component is rendering text transformed by predefined, standard `transform` functions: - **no-op**: the text is rendered as-is (_no operation_) - **lower-case**: use the standard `toLowerCase()` string transformation for rendition. - **upper-case**: use the standard `toUpperCase()` string transformation for rendition. - **camel-case**: starts by making the first word lowercase. Then, it capitalizes the first letter of each word that follows. Then It removes the non-letter chars from the text. - **pascal-case**: capitalizes the first letter of each word. Then It removes the non-letter chars from the text. - **snake-case**: separates each word with an underscore character (`_`). The rendered result is lowercased. - **kebab-case**: separates each word with a dash character (`-`). The rendered result is lowercased. - **to-base64**: renders a valid UTF-16 string to it's Base64 encoded representation. - **from-base64**: renders a valid Base64 string into it's UTF-16 decoded string representation. - **camel-to-kebab**: renders a camel-cased string into it's kebab-case representation. - **pascal-to-kebab**: renders a pascal-cased string into it's kebab-case representation.
2 parents 1307103 + 0d1a813 commit af2b6dc

17 files changed

+3981
-4188
lines changed

.github/workflows/publish-storybook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Generate test reports
3333
run: npm run test:ci
3434
- name: Build Storybook
35-
run: npm run build:storybook
35+
run: npm run storybook:build
3636
- name: Configure GH pages
3737
uses: actions/configure-pages@v5
3838
- name: Upload Storybook Documentation

.parcelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "@parcel/config-default",
3+
"bundler": "@parcel/bundler-library"
4+
}

.storybook/main.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
11
import type { StorybookConfig } from "@storybook/react-webpack5";
2+
import remarkGfm from 'remark-gfm';
23

34
const config: StorybookConfig = {
45
stories: ["../src/components/introduction.mdx", "../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
6+
57
addons: [
68
"@storybook/addon-webpack5-compiler-swc",
79
"@storybook/addon-links",
8-
"@storybook/addon-essentials"
10+
"@storybook/addon-essentials",
11+
{
12+
name: '@storybook/addon-docs',
13+
options: {
14+
mdxPluginOptions: {
15+
mdxCompileOptions: {
16+
remarkPlugins: [remarkGfm],
17+
},
18+
},
19+
},
20+
},
921
],
22+
1023
framework: {
1124
name: "@storybook/react-webpack5",
1225
options: { builder: { useSWC: true } }
1326
},
27+
1428
core: {
1529
disableTelemetry: true,
1630
},
31+
1732
typescript: {
1833
reactDocgen: 'react-docgen-typescript',
1934
},
35+
2036
build: {
2137
test: {
2238
disableBlocks: false,
@@ -28,7 +44,10 @@ const config: StorybookConfig = {
2844
disableTreeShaking: false
2945
}
3046
},
31-
staticDirs: ["../test-reports"]
47+
48+
staticDirs: ["../test-reports"],
49+
50+
docs: {}
3251
};
3352

3453
export default config;

.storybook/preview.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { Preview } from "@storybook/react";
22

3-
const preview: Preview = {};
3+
const preview: Preview = {
4+
// tags: ["autodocs"]
5+
};
46

57
export default preview;

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# react-text-renderer-components
22

3-
! MANAGE YOUR DATA, NOT THEIR STRING REPRESENTATION !
3+
⚡ MANAGE YOUR DATA OBJECTS, NOT THEIR STRING REPRESENTATION ⚡
44

55
This is a zero-dependencies component library providing a set of (pure) text rendering utility components. Those components are accepting common and custom data/field types as input and are rendering their text representation _automatically_.
66

@@ -12,7 +12,14 @@ e.g. to render the text corresponding to a `DateOfBirth` field (Date type) withi
1212
![GitHub Issues](https://img.shields.io/github/issues/khatastroffik/react-text-renderer-components)
1313
![Package size (minified)](<https://img.shields.io/bundlejs/size/%40khatastroffik%2Freact-text-renderer-components?label=Package%20size%20(minified)>)
1414

15-
## Documentation: Storybook, Changelog and Release note
15+
## Documentation: Demo, Storybook, Changelog and Release note
16+
17+
### Demo Webapp
18+
19+
A webapp demonstrating the usage of this library is available:
20+
21+
- Demo web app &rarr; [Demo - react-text-renderer-components](https://khatastroffik.github.io/react-text-renderer-components-demo)
22+
- Demo source code &rarr; [Github - react-text-renderer-components-demo](https://github.com/khatastroffik/react-text-renderer-components-demo)
1623

1724
### Storybook documentation
1825

@@ -31,6 +38,7 @@ Please read the [CHANGELOG](./CHANGELOG.md) (all changes since the beginning) an
3138
- `DateTimeRenderer` component ([Storybook &rarr; DateTimeRenderer](https://khatastroffik.github.io/react-text-renderer-components/?path=/docs/components-datetimerenderer--datetimerenderer-documentation))
3239
- `WeekRenderer` component ([Storybook &rarr; WeekRenderer](https://khatastroffik.github.io/react-text-renderer-components/?path=/docs/components-weekrenderer--weekrenderer-documentation))
3340
- `QuarterRenderer` component ([Storybook &rarr; QuarterRenderer](https://khatastroffik.github.io/react-text-renderer-components/?path=/docs/components-quarterrenderer--quarterrenderer-documentation))
41+
- `TextRenderer` component ([Storybook &rarr; TextRenderer](https://khatastroffik.github.io/react-text-renderer-components/?path=/docs/components-textrenderer--textrenderer-documentation))
3442

3543
more components to come... (see the ToDos below)
3644

@@ -105,7 +113,7 @@ This design allows to avoid repetitions, reduce the size of the compiled code us
105113

106114
-`WeekRenderer` component
107115
-`QuarterRenderer` component
108-
- `TextRenderer` component (with text manipulation like UpperCase, LowerCase, Replace...)
116+
- `TextRenderer` component (with text manipulation like UpperCase, LowerCase, SnakeCase, KebabCase, CamelCase, PascalCase, toBase64, fromBase64...)
109117
-`CurrencyRenderer` component
110118
-`CustomRenderer` component i.e the text formating function may be provided from the parent application/component using the CustomRenderer.
111119

@@ -294,6 +302,12 @@ npm install -D jest @testing-library/react ts-jest @types/jest ts-node @testing-
294302
- https://github.com/inttter/md-badges
295303
- https://shields.io/badges/dynamic-json-badge
296304

305+
### Base64
306+
307+
- https://developer.mozilla.org/de/docs/Web/API/Window/btoa#unicode-zeichenfolgen
308+
- https://developer.mozilla.org/de/docs/Web/API/DOMException#invalidcharactererror
309+
- https://web.dev/articles/base64-encoding?hl=de#put_it_all_together
310+
297311
### Divers
298312

299313
- https://www.pluralsight.com/resources/blog/guides/how-to-return-plain-text-from-a-react-component

0 commit comments

Comments
 (0)