@bitcredit/ui-library
v0.1.5-terms-bugfix
Published
Bitcredit design system and reusable React UI library.
Downloads
2,429
Keywords
Readme
@bitcredit/ui-library
Bitcredit design system and reusable React UI library.
Installation
Install the package together with its peer dependencies:
npm install @bitcredit/ui-library react react-domIf you consume the GitHub Packages build instead, use the published package name for that registry:
npm install @bitcreditprotocol/ui-library react react-domQuick Start
Import the library stylesheet once near your app entrypoint, then import the components you need:
import "@bitcredit/ui-library/style.css";
import { Button } from "@bitcredit/ui-library";
export function Example() {
return <Button>Continue</Button>;
}For predictable consumer behavior, treat the explicit style.css import as required public API.
The JS package entry currently carries the stylesheet through the library build, but consumers should not rely on implicit style loading.
The package ships:
dist/index.mjsfor ESM consumersdist/index.cjsfor CommonJS consumersdist/index.d.tsfor TypeScript typesdist/style.cssfor the shared library styles
CSS
This library currently expects consumers to load the exported stylesheet:
import "@bitcredit/ui-library/style.css";Without that import, many components will render without the expected design system styling.
Recommended pattern:
import "@bitcredit/ui-library/style.css";
import { Button, Card } from "@bitcredit/ui-library";Provider Setup
Some components and hooks depend on providers from the library. A common app-level setup looks like this:
import "@bitcredit/ui-library/style.css";
import {
LanguageProvider,
PreferencesProvider,
Toaster,
} from "@bitcredit/ui-library";
export function AppProviders({ children }: { children: React.ReactNode }) {
return (
<LanguageProvider>
<PreferencesProvider>
{children}
<Toaster />
</PreferencesProvider>
</LanguageProvider>
);
}Use the providers you actually need:
PreferencesProviderfor theme, currency, and decimal preferencesLanguageProviderforreact-intl-based localization helpersUiI18nProviderfor framework-agnostic shared UI message injectionToasterwhen using toast UI fromuseToast
Translation Strategy
For shared UI text, prefer app-owned translations with library-owned keys and fallbacks.
The library now exports:
UiTranslationKeydefaultUiMessagesUiI18nProvidergetUiText
Minimal example:
import "@bitcredit/ui-library/style.css";
import {
Button,
UiI18nProvider,
defaultUiMessages,
type UiTranslationKey,
} from "@bitcredit/ui-library";
const appMessages: Partial<Record<UiTranslationKey, string>> = {
"ui.upload.label": "Datei hochladen",
};
export function AppProviders({ children }: { children: React.ReactNode }) {
return <UiI18nProvider messages={appMessages}>{children}</UiI18nProvider>;
}You can also provide a translation function instead of a message map:
import { UiI18nProvider, type UiT } from "@bitcredit/ui-library";
const t: UiT = (key, params) => myI18n.translate(key, params);
export function AppProviders({ children }: { children: React.ReactNode }) {
return <UiI18nProvider t={t}>{children}</UiI18nProvider>;
}Current migration note:
- generic UI components can consume
UiI18nProvider - existing
react-intlconsumers continue to work - domain and app copy should stay in consuming apps
Example Imports
import {
Button,
Card,
DatePicker,
Input,
Search,
useToast,
} from "@bitcredit/ui-library";Package Notes
- The package is built in Vite library mode.
- Only library artifacts are published; app bundle files like
index.htmlare not part of the package. reactandreact-domare peer dependencies and must be provided by the consuming app.- Tailwind and Vite integration packages are build-time dependencies of this repository, not runtime requirements for consumers.
- TypeScript declarations are generated and published with the package.
Development
Useful local commands:
npm run dev
npm run storybook
npm run build
npm run test
npm run lint
npm run style:checkRepository
- Repository:
https://github.com/BitcreditProtocol/ui.git - Storybook and local component development remain part of this repository, but the published package is a consumable UI library.
