@c-code/c-code-fw 1.2.6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -0
- package/fesm2022/c-code-c-code-fw-ui.mjs +815 -0
- package/fesm2022/c-code-c-code-fw-ui.mjs.map +1 -0
- package/package.json +9 -2
- package/ui/index.d.ts +5 -0
- package/ui/lib/components/category-menu/category-menu.component.d.ts +19 -0
- package/ui/lib/components/faq/faq.component.d.ts +16 -0
- package/ui/lib/components/gallery/gallery.component.d.ts +27 -0
- package/ui/lib/components/info-item/info-item.component.d.ts +18 -0
- package/ui/lib/components/lightbox/lightbox.component.d.ts +26 -0
- package/ui/lib/components/page-banner/page-banner.component.d.ts +23 -0
- package/ui/lib/components/plan-card/plan-card.component.d.ts +23 -0
- package/ui/lib/components/plan-catalog/plan-catalog.component.d.ts +78 -0
- package/ui/lib/components/plan-details/plan-details.component.d.ts +44 -0
- package/ui/lib/components/plan-filter-form/plan-filter-form.component.d.ts +28 -0
- package/ui/lib/components/promo-modal/promo-modal.component.d.ts +24 -0
- package/ui/lib/components/search-box/search-box.component.d.ts +18 -0
- package/ui/lib/components/social-links/social-links.component.d.ts +17 -0
- package/ui/lib/components/whatsapp-button/whatsapp-button.component.d.ts +19 -0
- package/ui/lib/models/plan.models.d.ts +50 -0
- package/ui/lib/models/ui.models.d.ts +24 -0
- package/ui/lib/services/plan-catalog.service.d.ts +43 -0
- package/ui/lib/services/seo.service.d.ts +39 -0
- package/ui/lib/utils/plan.utils.d.ts +16 -0
- package/ui/lib/utils/text.utils.d.ts +15 -0
- package/ui/public-api.d.ts +20 -0
- package/ui/theme/tokens.css +45 -0
package/README.md
CHANGED
|
@@ -190,6 +190,110 @@ The `ScreenWidthEventService` uses Tailwind CSS breakpoints for responsive behav
|
|
|
190
190
|
|
|
191
191
|
---
|
|
192
192
|
|
|
193
|
+
## UI components: `@c-code/c-code-fw/ui`
|
|
194
|
+
|
|
195
|
+
Presentational components for spa and catalog sites. They are standalone Angular 19 components (signal inputs, OnPush) and work with SSR and prerendering. Styling is plain CSS driven by CSS variables, so a site needs no Tailwind configuration to use them.
|
|
196
|
+
|
|
197
|
+
### Setup
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
// app.config.ts
|
|
201
|
+
import { provideHttpClient, withFetch } from '@angular/common/http';
|
|
202
|
+
import { providePlanCatalog, provideSeo } from '@c-code/c-code-fw/ui';
|
|
203
|
+
|
|
204
|
+
export const appConfig: ApplicationConfig = {
|
|
205
|
+
providers: [
|
|
206
|
+
provideHttpClient(withFetch()),
|
|
207
|
+
providePlanCatalog(), // reads assets/data/{plans,additionals,priceRanges}.json
|
|
208
|
+
provideSeo({ siteUrl: 'https://www.example.com', defaultImage: '/assets/images/og.jpeg' }),
|
|
209
|
+
],
|
|
210
|
+
};
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Set the site palette in `styles.css`. Every variable is optional:
|
|
214
|
+
|
|
215
|
+
```css
|
|
216
|
+
:root {
|
|
217
|
+
--cc-primary: #4C6B4A;
|
|
218
|
+
--cc-primary-light: #A0BA9E;
|
|
219
|
+
--cc-primary-dark: #022B04;
|
|
220
|
+
--cc-secondary: #CEAB5D;
|
|
221
|
+
--cc-secondary-light: #f8f4ee;
|
|
222
|
+
--cc-secondary-dark: #9A7521;
|
|
223
|
+
--cc-bg: #F0FFEF;
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
A list of every token is in `node_modules/@c-code/c-code-fw/ui/theme/tokens.css`. You can add that file to `angular.json` → `styles`, or copy the variables you need.
|
|
228
|
+
|
|
229
|
+
Roles: by default each role follows a palette color. Set a role only when the site needs it to differ:
|
|
230
|
+
|
|
231
|
+
| Role | Used for | Default |
|
|
232
|
+
|---|---|---|
|
|
233
|
+
| `--cc-surface` | cards, sidebar, detail panel | `--cc-secondary-light` |
|
|
234
|
+
| `--cc-text` | text inside components | `--cc-primary` |
|
|
235
|
+
| `--cc-heading` | titles, price badge | `--cc-primary` |
|
|
236
|
+
| `--cc-accent` | buttons, highlighted titles | `--cc-secondary` |
|
|
237
|
+
| `--cc-accent-hover` | button hover | `--cc-secondary-dark` |
|
|
238
|
+
| `--cc-on-accent` | text on buttons and badges | `--cc-bg` |
|
|
239
|
+
| `--cc-font-heading` | title font | `inherit` |
|
|
240
|
+
|
|
241
|
+
### Components
|
|
242
|
+
|
|
243
|
+
All text has Spanish defaults, and every label can be changed through an input.
|
|
244
|
+
|
|
245
|
+
| Component | Main inputs | Outputs / notes |
|
|
246
|
+
|---|---|---|
|
|
247
|
+
| `<cc-plan-catalog>` | `plans`*, `services`, `priceRanges`, `categories`, `initialCategory`, `detailsLink`, `showCounts`, `showBanner`, `showSearch`, `titlePrefix`, `imageAltSuffix`, `emptyMessage`, `searchIconSrc`, `filterIconSrc` | `categoryChange`. The full plan list page. For a custom card: `<ng-template ccPlanCard let-plan let-link="link">` (import `PlanCardTemplateDirective`). |
|
|
248
|
+
| `<cc-plan-details>` | `plan`*, `bookingUrl`*, `bookingLabel`, `backLink`, `perks`, `perksTitle`, `perksImageSrc`, `titleIconSrc`, `durationIconSrc`, `personIconSrc`, `peopleIconSrc`, `currencyCode`, `currencyDisplay`, `imageAltSuffix` | Content in `<ng-content>` goes above the gift box; an element with the `ccDetailsMedia` attribute goes under the photo. |
|
|
249
|
+
| `<cc-plan-card>` | `name`*, `imageSrc`*, `link`, `ctaLabel`, `subtitle`, `imageAlt` | `ctaClick` |
|
|
250
|
+
| `<cc-category-menu>` | `options`*, `[(selected)]`, `title` | |
|
|
251
|
+
| `<cc-search-box>` | `[(value)]`, `placeholder`, `iconSrc` | `search` |
|
|
252
|
+
| `<cc-plan-filter-form>` | `services`, `priceRanges`, labels | `filterChange` |
|
|
253
|
+
| `<cc-page-banner>` | `title`*, `variant` (`band` \| `plain`), `iconSrc`, `backLink` | Renders the page `<h1>`. |
|
|
254
|
+
| `<cc-gallery>` | `images`*, `backgroundImage` | Opens `cc-lightbox`. `numberedImages(18, i => \`assets/galery/${i}.jpeg\`)` builds the list. |
|
|
255
|
+
| `<cc-lightbox>` | `images`*, `[(index)]` | Arrow keys and Escape. |
|
|
256
|
+
| `<cc-info-item>` | `title`*, `text` | Projects extra content (lists). |
|
|
257
|
+
| `<cc-faq>` | `items`*, `title` | Native `<details>`, prerendered. |
|
|
258
|
+
| `<cc-whatsapp-button>` | `href`*, `iconSrc`, `position`, `label` | Floating button. Without `iconSrc` it draws the WhatsApp logo. |
|
|
259
|
+
| `<cc-promo-modal>` | `[(open)]`, `imageSrc`, `imageAlt`, `link`, `closeOnBackdrop` | `closed`. Without `imageSrc` it shows the projected content. |
|
|
260
|
+
| `<cc-social-links>` | `links`*, `size`, `gap` | |
|
|
261
|
+
|
|
262
|
+
`*` required.
|
|
263
|
+
|
|
264
|
+
Component variables (they default to the roles above): `--cc-plan-card-width`, `--cc-plan-card-width-lg`, `--cc-plan-card-height`, `--cc-plan-card-bg`, `--cc-plan-card-cta-bg`, `--cc-catalog-column-min`, `--cc-catalog-panel-bg`, `--cc-category-active-bg`, `--cc-category-active-color`, `--cc-details-panel-bg`, `--cc-details-price-bg`, `--cc-details-gift-border`, `--cc-banner-bg`, `--cc-banner-color`, `--cc-banner-font-size`, `--cc-info-title-color`, `--cc-info-text-color`, `--cc-faq-bg`, `--cc-gallery-thumb-width`, `--cc-gallery-thumb-width-lg`, `--cc-gallery-columns-lg`, `--cc-whatsapp-size`, `--cc-whatsapp-size-lg`, `--cc-whatsapp-offset-x`, `--cc-whatsapp-offset-y`, `--cc-modal-backdrop`, `--cc-lightbox-backdrop`.
|
|
265
|
+
|
|
266
|
+
### Services and utilities
|
|
267
|
+
|
|
268
|
+
- `PlanCatalogService`: `getPlans()` (with `additionalServices` joined), `getAdditionalServices()`, `getPriceRanges()`, `getPlanBySlug()`, `getPlansByCategory()`, `getPlansByFilter()`, `getPlansByName()`. Each JSON file is requested once and cached. Configure the paths with `providePlanCatalog({ plansUrl, additionalsUrl, priceRangesUrl })`; pass `priceRangesUrl: null` if the site has no price ranges.
|
|
269
|
+
- `SeoService`: `update({ title, description, path, image })` sets the title, description, canonical URL and Open Graph/Twitter tags. `setJsonLd(id, data)` and `removeJsonLd(id)` manage JSON-LD blocks.
|
|
270
|
+
- Pure functions: `slugify`, `planSlug`, `findPlanBySlug`, `filterPlans`, `filterPlansByCategory`, `searchPlansByName`, `withCategoryCounts`, `joinAdditionalServices`, `whatsappUrl(phone, message)`, `titleCase`, `truncateText`.
|
|
271
|
+
- Models: `Plan`, `AdditionalService`, `PriceRange`, `PlanFilter`, `PlanCategory`, `CategoryOption`, `GalleryImage`, `SocialLink`, `FaqItem`.
|
|
272
|
+
|
|
273
|
+
### Example: plan list page
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
277
|
+
import { PlanCatalogComponent, PlanCatalogService } from '@c-code/c-code-fw/ui';
|
|
278
|
+
|
|
279
|
+
@Component({
|
|
280
|
+
imports: [PlanCatalogComponent],
|
|
281
|
+
template: `<cc-plan-catalog [plans]="plans()" [services]="services()" [priceRanges]="ranges()" />`,
|
|
282
|
+
})
|
|
283
|
+
export class PlanListComponent {
|
|
284
|
+
private catalog = inject(PlanCatalogService);
|
|
285
|
+
plans = toSignal(this.catalog.getPlans(), { initialValue: [] });
|
|
286
|
+
services = toSignal(this.catalog.getAdditionalServices(), { initialValue: [] });
|
|
287
|
+
ranges = toSignal(this.catalog.getPriceRanges(), { initialValue: [] });
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Development
|
|
292
|
+
|
|
293
|
+
`npx ng serve showcase` runs a playground with every component at http://localhost:4200. It loads the data and images from `../medellin-spa/src/assets`, and `?theme=xora` switches to a second palette.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
193
297
|
## Contributing
|
|
194
298
|
|
|
195
299
|
Feel free to contribute to this library by submitting issues or pull requests.
|