|
| 1 | +# DB UX Design System v3 Core Web |
| 2 | + |
| 3 | +DB UX Design System v3 Core Web is a monorepo containing CSS/SCSS styles, components, and framework-specific implementations (Angular, React, Vue, Web Components) for the Deutsche Bahn design system. |
| 4 | + |
| 5 | +**Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.** |
| 6 | + |
| 7 | +## Working Effectively |
| 8 | + |
| 9 | +### Required Prerequisites |
| 10 | +- **Node.js 24**: Check `.nvmrc` file. Use `node --version` to verify current version. |
| 11 | +- **npm**: Package manager for dependency management and build scripts. |
| 12 | + |
| 13 | +### Bootstrap and Setup |
| 14 | +1. **CRITICAL**: Copy `.env.template` to `.env` and add your email: |
| 15 | + ```bash |
| 16 | + cp .env.template .env |
| 17 | + # Edit .env file: Set COMMIT_MAIL=your.email@example.com |
| 18 | + ``` |
| 19 | + |
| 20 | +2. **Install dependencies**: |
| 21 | + ```bash |
| 22 | + npm install --ignore-scripts |
| 23 | + |
| 24 | + **NOTE**: Use the `--ignore-scripts` flag because the chromedriver package attempts to download binaries during installation, which fails in restricted corporate networks (e.g., behind firewalls or proxies). This workaround prevents installation errors in such environments. |
| 25 | + |
| 26 | +3. **Decode DB Theme assets** (optional for basic development): |
| 27 | + ```bash |
| 28 | + node node_modules/@db-ux/db-theme-fonts/build/scripts/index.js |
| 29 | + node node_modules/@db-ux/db-theme-icons/build/scripts/index.js |
| 30 | + node node_modules/@db-ux/db-theme-illustrative-icons/build/scripts/index.js |
| 31 | + ``` |
| 32 | + **NOTE**: These will fail with placeholder credentials in `.env` but are not required for basic development. |
| 33 | + |
| 34 | +### Build and Test |
| 35 | +- **Build core packages**: |
| 36 | + ```bash |
| 37 | + npm run build |
| 38 | + ``` |
| 39 | + **TIMING**: Takes ~30 seconds. NEVER CANCEL. Set timeout to 120+ seconds. |
| 40 | + |
| 41 | +- **Build all framework outputs**: |
| 42 | + ```bash |
| 43 | + npm run build-outputs |
| 44 | + ``` |
| 45 | + **TIMING**: Takes ~2 minutes. NEVER CANCEL. Set timeout to 300+ seconds. |
| 46 | + |
| 47 | +- **Run tests**: |
| 48 | + ```bash |
| 49 | + npm run test |
| 50 | + ``` |
| 51 | + **TIMING**: Takes ~10 seconds. NEVER CANCEL. Set timeout to 60+ seconds. |
| 52 | + |
| 53 | +### Development |
| 54 | +- **Start interactive development server**: |
| 55 | + ```bash |
| 56 | + npm run dev |
| 57 | + ``` |
| 58 | + **Interactive**: Will prompt to select frameworks (plain-html, angular, react, vue, stencil, etc.). Default selection is plain-html. |
| 59 | + **TIMING**: Takes ~30 seconds to start. Runs on <http://localhost:5173/> |
| 60 | + |
| 61 | +- **Start documentation site (Patternhub)**: |
| 62 | + ```bash |
| 63 | + npm run start |
| 64 | + ``` |
| 65 | + **TIMING**: Takes ~2 minutes to start. NEVER CANCEL. Set timeout to 300+ seconds. |
| 66 | + **ACCESS**: Runs on <http://localhost:3000> - full design system documentation and examples. |
| 67 | + |
| 68 | +## Validation |
| 69 | + |
| 70 | +### Always Run These Commands Before Committing |
| 71 | +```bash |
| 72 | +npm run build # Verify core packages build |
| 73 | +npm run test # Verify all tests pass |
| 74 | +npm run lint # NOTE: May fail if Nuxt showcase hasn't been run yet - this is known |
| 75 | +npm run build-outputs # Verify framework outputs build |
| 76 | +``` |
| 77 | + |
| 78 | +### Manual Validation Scenarios |
| 79 | +**ALWAYS test actual functionality after making changes:** |
| 80 | + |
| 81 | +1. **Component Development Validation**: |
| 82 | + - Run `npm run dev` and select `plain-html` |
| 83 | + - Open <http://localhost:5173/> in browser |
| 84 | + - Navigate to components and verify visual rendering |
| 85 | + - Test interactive components (buttons, forms, etc.) |
| 86 | + |
| 87 | +2. **Documentation Site Validation**: |
| 88 | + - Run `npm run start` |
| 89 | + - Open <http://localhost:3000> in browser |
| 90 | + - Navigate through component documentation |
| 91 | + - Verify code examples render correctly |
| 92 | + |
| 93 | +3. **Framework-Specific Validation**: |
| 94 | + - Run `npm run dev` and select target framework (react, vue, angular) |
| 95 | + - Test component integration in selected framework |
| 96 | + - Verify framework-specific showcase builds: `npm run build-showcases` |
| 97 | + |
| 98 | +### Visual Regression Testing |
| 99 | +**E2E testing with Playwright** (requires Docker): |
| 100 | +```bash |
| 101 | +# Generate/update screenshots: |
| 102 | +npm run regenerate:screenshots |
| 103 | +# Test visual regression: |
| 104 | +docker-compose --file ./e2e/docker-compose.yml up |
| 105 | +``` |
| 106 | +**TIMING**: Visual tests take 10+ minutes. NEVER CANCEL. Set timeout to 1800+ seconds. |
| 107 | + |
| 108 | +## Common Tasks |
| 109 | + |
| 110 | +### Working with Components |
| 111 | +- **Generate new component**: `npm run generate:component` |
| 112 | +- **Component build location**: `packages/components/build/` |
| 113 | +- **Framework outputs**: `output/react/`, `output/vue/`, `output/angular/`, `output/stencil/` |
| 114 | + |
| 115 | +### Working with Styles |
| 116 | +- **Foundation styles**: `packages/foundations/` |
| 117 | +- **Component styles**: `packages/components/src/styles/` |
| 118 | +- **Build artifacts**: `packages/foundations/build/` and `packages/components/build/` |
| 119 | + |
| 120 | +### Key Repository Locations |
| 121 | + |
| 122 | +```text |
| 123 | +├── packages/ |
| 124 | +│ ├── foundations/ # Base CSS/SCSS styles and design tokens |
| 125 | +│ ├── components/ # Component CSS and build definitions |
| 126 | +│ ├── migration/ # Migration utilities between versions |
| 127 | +│ └── stylelint/ # DB UX Design System Stylelint plugin for QS |
| 128 | +├── output/ # Framework-specific generated code |
| 129 | +│ ├── angular/ # Angular components (@db-ux/ngx-core-components) |
| 130 | +│ ├── react/ # React components (@db-ux/react-core-components) |
| 131 | +│ ├── vue/ # Vue 3 components (@db-ux/v-core-components) |
| 132 | +│ └── stencil/ # Web Components (@db-ux/wc-core-components) |
| 133 | +├── showcases/ # Example applications for each framework |
| 134 | +├── e2e/ # End-to-end testing with Playwright |
| 135 | +└── docs/ # Documentation files |
| 136 | +``` |
| 137 | + |
| 138 | +### Package Scripts Reference |
| 139 | +```bash |
| 140 | +# Development |
| 141 | +npm run dev # Interactive dev server (framework selection) |
| 142 | +npm run start # Start Patternhub documentation site |
| 143 | +
|
| 144 | +# Building |
| 145 | +npm run build # Build core packages (~30 seconds) |
| 146 | +npm run build-outputs # Build all framework outputs (~2 minutes) |
| 147 | +npm run build-showcases # Build example applications |
| 148 | +
|
| 149 | +# Testing & Quality |
| 150 | +npm run test # Run test suite (~10 seconds) |
| 151 | +npm run lint # Run all linters (known issue: may fail if Nuxt showcase hasn't been run yet; see "Known Issues and Workarounds" below) |
| 152 | +npm run regenerate:screenshots # Update visual regression tests material |
| 153 | +
|
| 154 | +# Utilities |
| 155 | +npm run clean # Clean build artifacts |
| 156 | +npm run generate:component # Generate new component scaffolding |
| 157 | +``` |
| 158 | + |
| 159 | +## Known Issues and Workarounds |
| 160 | + |
| 161 | +### Installation Issues |
| 162 | +- **chromedriver fails**: Use `npm install --ignore-scripts` - this is expected in restricted network environments |
| 163 | +- **Font decoding fails**: Expected with placeholder credentials - does not affect basic development |
| 164 | + |
| 165 | +### Build Issues |
| 166 | +- **Nuxt-related linting failures**: May fail if Nuxt showcase hasn't been run yet (requires `showcases/nuxt-showcase/.nuxt/tsconfig.json` to be generated) |
| 167 | +- **Stencil warnings**: Component prop name conflicts are expected and documented |
| 168 | +
|
| 169 | +### Network Restrictions |
| 170 | +- **Docker registry access**: E2E testing requires Docker and may need proxy configuration |
| 171 | +- **Asset downloads**: DB Theme assets require valid credentials from Deutsche Bahn Marketing Portal |
| 172 | +
|
| 173 | +## Development Workflows |
| 174 | +
|
| 175 | +### Adding a New Component |
| 176 | +1. `npm run generate:component` - Follow interactive prompts |
| 177 | +2. Implement component in `packages/components/src/components/[name]/` |
| 178 | +3. Build and test: `npm run build && npm run test` |
| 179 | +4. Generate framework outputs: `npm run build-outputs` |
| 180 | +5. Test in development server: `npm run dev` |
| 181 | +
|
| 182 | +### Modifying Existing Components |
| 183 | +1. Make changes in `packages/components/src/components/[name]/` |
| 184 | +2. Adapt those changes into the `showcases/vue-showcase`, `showcases/angular-showcase` and `showcases/react-showcase` folders. |
| 185 | +3. **Always run**: `npm run build && npm run dev` |
| 186 | +4. **Manual validation**: Test component behavior in browser |
| 187 | +5. **Before committing**: `npm run test && npm run build-outputs` |
| 188 | +
|
| 189 | +### Debugging Build Issues |
| 190 | +1. **Check Node.js version**: Must be v24 (see `.nvmrc`) |
| 191 | +2. **Clean rebuild**: `npm run clean && npm run build` |
| 192 | +3. **Check dependencies**: `npm install --ignore-scripts` |
| 193 | +4. **Isolate issue**: Build individual packages using workspace commands |
| 194 | +
|
| 195 | +Remember: This is a design system used by Deutsche Bahn applications. Always ensure changes maintain accessibility, consistency, and brand compliance. |
0 commit comments