@bailaya/react 1.0.14 → 1.0.16

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 CHANGED
@@ -6,39 +6,37 @@
6
6
 
7
7
  `@bailaya/react` builds on top of **@bailaya/core** to provide:
8
8
 
9
- - A **`BailayaProvider`** + **`useBailayaClient`** context
10
- - React **hooks** for fetching all core data (with `loading`, `error`, `data`, and `refetch`)
11
- - **Components** with sensible Tailwind defaults (and full styling slots)
12
- - Full TypeScript support, including localized text & date formatting
9
+ * A **`BailayaProvider`** + **`useBailayaClient`** context
10
+ * React **hooks** for fetching all core data (with `loading`, `error`, `data`, and `refetch`)
11
+ * **Components** with sensible Tailwind defaults (and full styling slots)
12
+ * Full TypeScript support, including localized text & date formatting
13
13
 
14
- Whether you need a quick `<StudioProfileCard />` or fine-grained hooks like `useClassesByType()`, this package has you covered.
14
+ > Works **with or without Tailwind**. If you don’t use Tailwind, just override the class props (or use the render props) to apply your own styling.
15
15
 
16
16
  ## Features
17
17
 
18
- - **Context + client** (`BailayaProvider` + `useBailayaClient`)
19
- - **Hooks** (all return `{ data, error, loading, refetch }`)
20
- - `useStudioProfile(overrideId?)`
21
- - `useUserProfile(userId)`
22
- - `useInstructors(overrideId?)`
23
- - `useClasses(from?, overrideId?)`
24
- - `useClassesByType(typeName, from?, overrideId?)`
25
- - **Components** (all props overridable)
26
- - `<StudioProfileCard />`
27
- - `<UserProfileCard />`
28
- - `<InstructorList />`
29
- - `<ClassSchedule />`
30
- - `<ClassScheduleByType />`
31
- - `<StudioDescription />`
32
- - **Localization**
33
- - Select description by `locale` prop
34
- - Date formatting via Intl
35
- - Custom text labels
18
+ * **Context + client** (`BailayaProvider` + `useBailayaClient`)
19
+ * **Hooks** (all return `{ data, error, loading, refetch }`)
20
+
21
+ * `useStudioProfile(overrideId?)`
22
+ * `useUserProfile(userId)`
23
+ * `useInstructors(overrideId?)`
24
+ * `useClasses(from?, overrideId?)`
25
+ * `useClassesByType(typeName, from?, overrideId?)`
26
+ * **Components** (all props overridable)
27
+
28
+ * `<StudioProfileCard />`
29
+ * `<UserProfileCard />`
30
+ * `<InstructorList />`
31
+ * `<ClassSchedule />`
32
+ * `<ClassScheduleByType />`
33
+ * `<StudioDescription />`
36
34
 
37
35
  ## Installation
38
36
 
39
37
  ```bash
40
38
  npm install @bailaya/react
41
- ````
39
+ ```
42
40
 
43
41
  or with Yarn:
44
42
 
@@ -51,6 +49,52 @@ yarn add @bailaya/react
51
49
  > * `"react": ">=17"`
52
50
  > * `"react-dom": ">=17"`
53
51
 
52
+ ---
53
+
54
+ ## Tailwind Setup (optional)
55
+
56
+ If your app uses Tailwind, add this glob so JIT scans our package classes:
57
+
58
+ ```js
59
+ // tailwind.config.js or tailwind.config.ts
60
+ module.exports = {
61
+ content: [
62
+ './node_modules/@bailaya/**/*.{js,mjs,ts,tsx}',
63
+ ],
64
+ }
65
+ ```
66
+
67
+ > If you’re not using Tailwind, skip this section.
68
+
69
+ ---
70
+
71
+ ## Styling without Tailwind
72
+
73
+ You can use all components in non-Tailwind projects:
74
+
75
+ * Pass your own `className`/`*ClassName` props to inject your CSS classes.
76
+ * Or use `renderItem` / `renderProfile` props to fully control markup.
77
+
78
+ ```tsx
79
+ import { InstructorList } from '@bailaya/react'
80
+
81
+ export function Team() {
82
+ return (
83
+ <InstructorList
84
+ className="team"
85
+ itemClassName="card"
86
+ imageWrapperClassName="avatarWrap"
87
+ imageClassName="avatar"
88
+ bodyClassName="cardBody"
89
+ nameClassName="cardTitle"
90
+ bioClassName="cardText"
91
+ />
92
+ )
93
+ }
94
+ ```
95
+
96
+ ---
97
+
54
98
  ## Quick Start
55
99
 
56
100
  First, wrap your app with **BailayaProvider**:
@@ -69,8 +113,6 @@ export default function App() {
69
113
  }
70
114
  ```
71
115
 
72
- ---
73
-
74
116
  ### Using a Hook
75
117
 
76
118
  ```tsx
@@ -96,8 +138,6 @@ export function TeamSection() {
96
138
  }
97
139
  ```
98
140
 
99
- ---
100
-
101
141
  ### Using a Component
102
142
 
103
143
  ```tsx
@@ -107,10 +147,7 @@ import { StudioProfileCard } from "@bailaya/react";
107
147
  export function Dashboard() {
108
148
  return (
109
149
  <div className="max-w-md mx-auto">
110
- <StudioProfileCard
111
- locale="en"
112
- className="bg-white rounded-lg shadow p-6"
113
- />
150
+ <StudioProfileCard locale="en" />
114
151
  </div>
115
152
  );
116
153
  }
@@ -0,0 +1,52 @@
1
+ import React from "react";
2
+ import type { StudioType, StudioProfile } from "@bailaya/core";
3
+ export interface StudioTypesGridProps {
4
+ /** Optional studio ID to override the default configured ID */
5
+ overrideId?: string;
6
+ /** Locale code (e.g., "en", "es") for localized descriptions (if shown) */
7
+ locale?: string;
8
+ /** Root grid wrapper */
9
+ className?: string;
10
+ /** Each card wrapper */
11
+ itemClassName?: string;
12
+ /** Wrapper around the image */
13
+ imageWrapperClassName?: string;
14
+ /** The `<img>` element itself */
15
+ imageClassName?: string;
16
+ /** Container for title (+ optional description) + CTA */
17
+ bodyClassName?: string;
18
+ /** Dance name heading */
19
+ titleClassName?: string;
20
+ /** Optional description paragraph (if you enable it) */
21
+ descriptionClassName?: string;
22
+ /** CTA button/link class */
23
+ buttonClassName?: string;
24
+ /** Text for the CTA (i18n-friendly). Default: "See Classes" */
25
+ seeClassesText?: string;
26
+ /** Prefix for the href. Default: "/classes/" */
27
+ hrefPrefix?: string;
28
+ /** Hide the CTA entirely. Default: false */
29
+ hideButton?: boolean;
30
+ /**
31
+ * Optional link renderer to use custom component.
32
+ * If not provided, a plain <a> will be rendered.
33
+ */
34
+ renderLink?: (opts: {
35
+ href: string;
36
+ className?: string;
37
+ children: React.ReactNode;
38
+ }) => React.ReactNode;
39
+ /** Optional custom render for each studio type; bypasses the default card layout entirely. */
40
+ renderItem?: (type: StudioType, profile: StudioProfile) => React.ReactNode;
41
+ /** Show localized description text under the title. Default: false */
42
+ showDescription?: boolean;
43
+ /** Optional filter/sort hook before render */
44
+ transformTypes?: (types: StudioType[]) => StudioType[];
45
+ /** Optional custom href builder; defaults to hrefPrefix + slug(name) */
46
+ hrefBuilder?: (type: StudioType) => string;
47
+ }
48
+ /**
49
+ * Grid of studio dance types (Salsa, Bachata, etc.) with optional CTA button.
50
+ */
51
+ export declare const StudioTypesGrid: React.FC<StudioTypesGridProps>;
52
+ //# sourceMappingURL=StudioTypesGrid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StudioTypesGrid.d.ts","sourceRoot":"","sources":["../../src/components/StudioTypesGrid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAyB/D,MAAM,WAAW,oBAAoB;IACjC,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,wBAAwB;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,+BAA+B;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,yBAAyB;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,wDAAwD;IACxD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,4BAA4B;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAC;IAExG,8FAA8F;IAC9F,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,KAAK,KAAK,CAAC,SAAS,CAAC;IAE3E,sEAAsE;IACtE,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,8CAA8C;IAC9C,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,CAAC;IAEvD,wEAAwE;IACxE,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,MAAM,CAAC;CAC9C;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA+E1D,CAAC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ "use client";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.StudioTypesGrid = void 0;
8
+ const react_1 = __importDefault(require("react"));
9
+ const lucide_react_1 = require("lucide-react");
10
+ const useStudioProfile_1 = require("../hooks/useStudioProfile");
11
+ const LoadingIcon_1 = require("./ui/LoadingIcon");
12
+ /** Picks localized text with fallback to first available. */
13
+ function pickLocalizedText(map, locale) {
14
+ const obj = map !== null && map !== void 0 ? map : {};
15
+ if (locale && obj[locale])
16
+ return obj[locale];
17
+ const keys = Object.keys(obj);
18
+ return keys.length ? obj[keys[0]] : "";
19
+ }
20
+ /** Slugify dance names: lower, spaces→hyphens, strip accents & non-alphanum. */
21
+ function slugifyName(name) {
22
+ return name
23
+ .normalize("NFD")
24
+ .replace(/[\u0300-\u036f]/g, "") // strip accents
25
+ .toLowerCase()
26
+ .replace(/[^a-z0-9\s-]/g, "") // remove special chars
27
+ .trim()
28
+ .replace(/\s+/g, "-");
29
+ }
30
+ /**
31
+ * Grid of studio dance types (Salsa, Bachata, etc.) with optional CTA button.
32
+ */
33
+ const StudioTypesGrid = ({ overrideId, locale, className = "my-3 md:my-6 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8", itemClassName = "flex flex-col rounded-lg border border-[#DCDCDC] shadow-lg overflow-hidden", imageWrapperClassName = "w-full aspect-square p-2", imageClassName = "w-full h-full object-cover", bodyClassName = "p-3 flex flex-col flex-1", titleClassName = "text-3xl md:text-5xl font-geologica font-semibold text-[#2A2343] pb-4 text-start", descriptionClassName = "text-sm md:text-base text-[#464646] pb-3", buttonClassName = "mt-auto inline-flex items-center gap-2 px-6 py-3 rounded-md font-medium border border-transparent shadow-sm bg-[#2A2343] text-white hover:opacity-90 transition", seeClassesText = "See Classes", hrefPrefix = "/classes/", hideButton = false, renderLink, renderItem, showDescription = false, transformTypes, hrefBuilder, }) => {
34
+ var _a;
35
+ const { data: profile, loading, error } = (0, useStudioProfile_1.useStudioProfile)(overrideId);
36
+ if (loading)
37
+ return react_1.default.createElement("div", { className: className },
38
+ react_1.default.createElement(LoadingIcon_1.LoadingIcon, null));
39
+ if (error)
40
+ return react_1.default.createElement("div", { className: className }, error.message);
41
+ if (!profile || !((_a = profile.studioTypes) === null || _a === void 0 ? void 0 : _a.length))
42
+ return react_1.default.createElement("div", { className: className });
43
+ const types = transformTypes ? transformTypes(profile.studioTypes) : profile.studioTypes;
44
+ return (react_1.default.createElement("div", { className: className }, types.map((type) => {
45
+ if (renderItem) {
46
+ return react_1.default.createElement(react_1.default.Fragment, { key: type.name }, renderItem(type, profile));
47
+ }
48
+ const href = hrefBuilder
49
+ ? hrefBuilder(type)
50
+ : `${hrefPrefix}${slugifyName(type.name)}`;
51
+ return (react_1.default.createElement("div", { key: type.name, className: itemClassName },
52
+ type.image && (react_1.default.createElement("div", { className: imageWrapperClassName },
53
+ react_1.default.createElement("img", { src: type.image, alt: type.name, className: imageClassName }))),
54
+ react_1.default.createElement("div", { className: bodyClassName },
55
+ react_1.default.createElement("h3", { className: titleClassName }, type.name),
56
+ showDescription && type.description && (react_1.default.createElement("p", { className: descriptionClassName }, pickLocalizedText(type.description, locale))),
57
+ !hideButton && (renderLink
58
+ ? renderLink({
59
+ href,
60
+ className: buttonClassName,
61
+ children: (react_1.default.createElement(react_1.default.Fragment, null,
62
+ seeClassesText,
63
+ " ",
64
+ react_1.default.createElement(lucide_react_1.ArrowRight, null))),
65
+ })
66
+ : (react_1.default.createElement("a", { href: href, className: buttonClassName },
67
+ seeClassesText,
68
+ " ",
69
+ react_1.default.createElement(lucide_react_1.ArrowRight, null)))))));
70
+ })));
71
+ };
72
+ exports.StudioTypesGrid = StudioTypesGrid;
package/dist/index.d.ts CHANGED
@@ -21,6 +21,7 @@ export { ClassSchedule, ClassScheduleProps } from './components/ClassSchedule';
21
21
  export { ClassScheduleByType, ClassScheduleByTypeProps } from './components/ClassScheduleByType';
22
22
  export { InstructorList, InstructorListProps } from './components/InstructorList';
23
23
  export { StudioProfileCard, StudioProfileCardProps } from './components/StudioProfileCard';
24
+ export { StudioTypesGrid, StudioTypesGridProps } from './components/StudioTypesGrid';
24
25
  export { UserProfileCard, UserProfileCardProps } from './components/UserProfileCard';
25
26
  export { StudioDescription } from './components/StudioDescription';
26
27
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE9E;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;A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OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;GAEG;AACH,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.StudioDescription = exports.UserProfileCard = exports.StudioProfileCard = exports.InstructorList = exports.ClassScheduleByType = exports.ClassSchedule = exports.useClassesByType = exports.useClasses = exports.useInstructors = exports.useStudioProfile = exports.useBailayaClient = exports.BailayaProvider = void 0;
22
+ exports.StudioDescription = exports.UserProfileCard = exports.StudioTypesGrid = exports.StudioProfileCard = exports.InstructorList = exports.ClassScheduleByType = exports.ClassSchedule = exports.useClassesByType = exports.useClasses = exports.useInstructors = exports.useStudioProfile = exports.useBailayaClient = exports.BailayaProvider = void 0;
23
23
  /**
24
24
  * Re-exported context and hooks for easy import
25
25
  */
@@ -48,6 +48,8 @@ var InstructorList_1 = require("./components/InstructorList");
48
48
  Object.defineProperty(exports, "InstructorList", { enumerable: true, get: function () { return InstructorList_1.InstructorList; } });
49
49
  var StudioProfileCard_1 = require("./components/StudioProfileCard");
50
50
  Object.defineProperty(exports, "StudioProfileCard", { enumerable: true, get: function () { return StudioProfileCard_1.StudioProfileCard; } });
51
+ var StudioTypesGrid_1 = require("./components/StudioTypesGrid");
52
+ Object.defineProperty(exports, "StudioTypesGrid", { enumerable: true, get: function () { return StudioTypesGrid_1.StudioTypesGrid; } });
51
53
  var UserProfileCard_1 = require("./components/UserProfileCard");
52
54
  Object.defineProperty(exports, "UserProfileCard", { enumerable: true, get: function () { return UserProfileCard_1.UserProfileCard; } });
53
55
  var StudioDescription_1 = require("./components/StudioDescription");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bailaya/react",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "A React component library for the BailaYa public API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",