@bailaya/react 1.0.15 → 1.0.17
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.
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { StudioType, StudioProfile } from "@bailaya/core";
|
|
3
|
+
import "./studio-types-grid.css";
|
|
4
|
+
export interface StudioTypesGridProps {
|
|
5
|
+
overrideId?: string;
|
|
6
|
+
locale?: string;
|
|
7
|
+
/** Root grid wrapper */
|
|
8
|
+
className?: string;
|
|
9
|
+
/** Each card wrapper */
|
|
10
|
+
itemClassName?: string;
|
|
11
|
+
/** Wrapper around the image */
|
|
12
|
+
imageWrapperClassName?: string;
|
|
13
|
+
/** The `<img>` element itself */
|
|
14
|
+
imageClassName?: string;
|
|
15
|
+
/** Container for title (+ optional description) + CTA */
|
|
16
|
+
bodyClassName?: string;
|
|
17
|
+
/** Dance name heading */
|
|
18
|
+
titleClassName?: string;
|
|
19
|
+
/** Optional description paragraph (if you enable it) */
|
|
20
|
+
descriptionClassName?: string;
|
|
21
|
+
/** CTA button/link class */
|
|
22
|
+
buttonClassName?: string;
|
|
23
|
+
/** Text for the CTA (i18n-friendly). Default: "See Classes" */
|
|
24
|
+
seeClassesText?: string;
|
|
25
|
+
/** Prefix for the href. Default: "/classes/" */
|
|
26
|
+
hrefPrefix?: string;
|
|
27
|
+
/** Hide the CTA entirely. Default: false */
|
|
28
|
+
hideButton?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Optional link renderer.
|
|
31
|
+
* If not provided, a plain <a> will be rendered.
|
|
32
|
+
*/
|
|
33
|
+
renderLink?: (opts: {
|
|
34
|
+
href: string;
|
|
35
|
+
className?: string;
|
|
36
|
+
children: React.ReactNode;
|
|
37
|
+
}) => React.ReactNode;
|
|
38
|
+
/** Optional custom render for each studio type; bypasses default layout */
|
|
39
|
+
renderItem?: (type: StudioType, profile: StudioProfile) => React.ReactNode;
|
|
40
|
+
/** Show localized description text under the title. Default: false */
|
|
41
|
+
showDescription?: boolean;
|
|
42
|
+
/** Optional filter/sort hook before render */
|
|
43
|
+
transformTypes?: (types: StudioType[]) => StudioType[];
|
|
44
|
+
/** Optional custom href builder; defaults to hrefPrefix + slug(name) */
|
|
45
|
+
hrefBuilder?: (type: StudioType) => string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Grid of studio dance types (Salsa, Bachata, etc.) with optional CTA button.
|
|
49
|
+
*/
|
|
50
|
+
export declare const StudioTypesGrid: React.FC<StudioTypesGridProps>;
|
|
51
|
+
//# 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;AAE/D,OAAO,yBAAyB,CAAC;AAwBjC,MAAM,WAAW,oBAAoB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+BAA+B;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yBAAyB;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wDAAwD;IACxD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,4BAA4B;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;KAC7B,KAAK,KAAK,CAAC,SAAS,CAAC;IAEtB,2EAA2E;IAC3E,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,CA4E1D,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
require("./studio-types-grid.css");
|
|
13
|
+
/** Picks localized text with fallback to first available. */
|
|
14
|
+
function pickLocalizedText(map, locale) {
|
|
15
|
+
const obj = map !== null && map !== void 0 ? map : {};
|
|
16
|
+
if (locale && obj[locale])
|
|
17
|
+
return obj[locale];
|
|
18
|
+
const keys = Object.keys(obj);
|
|
19
|
+
return keys.length ? obj[keys[0]] : "";
|
|
20
|
+
}
|
|
21
|
+
/** Slugify dance names: lower, spaces→hyphens, strip accents & non-alphanum. */
|
|
22
|
+
function slugifyName(name) {
|
|
23
|
+
return name
|
|
24
|
+
.normalize("NFD")
|
|
25
|
+
.replace(/[\u0300-\u036f]/g, "") // strip accents
|
|
26
|
+
.toLowerCase()
|
|
27
|
+
.replace(/[^a-z0-9\s-]/g, "") // remove special chars
|
|
28
|
+
.trim()
|
|
29
|
+
.replace(/\s+/g, "-");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Grid of studio dance types (Salsa, Bachata, etc.) with optional CTA button.
|
|
33
|
+
*/
|
|
34
|
+
const StudioTypesGrid = ({ overrideId, locale, className = "by-classesGrid", itemClassName = "by-card", imageWrapperClassName = "by-imageWrap", imageClassName = "by-img", bodyClassName = "by-body", titleClassName = "by-title", descriptionClassName = "by-desc", buttonClassName = "by-btn", seeClassesText = "See Classes", hrefPrefix = "/classes/", hideButton = false, renderLink, renderItem, showDescription = false, transformTypes, hrefBuilder, }) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const { data: profile, loading, error } = (0, useStudioProfile_1.useStudioProfile)(overrideId);
|
|
37
|
+
if (loading)
|
|
38
|
+
return react_1.default.createElement("div", { className: className },
|
|
39
|
+
react_1.default.createElement(LoadingIcon_1.LoadingIcon, null));
|
|
40
|
+
if (error)
|
|
41
|
+
return react_1.default.createElement("div", { className: className }, error.message);
|
|
42
|
+
if (!profile || !((_a = profile.studioTypes) === null || _a === void 0 ? void 0 : _a.length))
|
|
43
|
+
return react_1.default.createElement("div", { className: className });
|
|
44
|
+
const types = transformTypes ? transformTypes(profile.studioTypes) : profile.studioTypes;
|
|
45
|
+
return (react_1.default.createElement("div", { className: className }, types.map((type) => {
|
|
46
|
+
if (renderItem) {
|
|
47
|
+
return react_1.default.createElement(react_1.default.Fragment, { key: type.name }, renderItem(type, profile));
|
|
48
|
+
}
|
|
49
|
+
const href = hrefBuilder ? hrefBuilder(type) : `${hrefPrefix}${slugifyName(type.name)}`;
|
|
50
|
+
return (react_1.default.createElement("div", { key: type.name, className: itemClassName },
|
|
51
|
+
type.image && (react_1.default.createElement("div", { className: imageWrapperClassName },
|
|
52
|
+
react_1.default.createElement("img", { src: type.image, alt: type.name, className: imageClassName }))),
|
|
53
|
+
react_1.default.createElement("div", { className: bodyClassName },
|
|
54
|
+
react_1.default.createElement("h3", { className: titleClassName }, type.name),
|
|
55
|
+
showDescription && type.description && (react_1.default.createElement("p", { className: descriptionClassName }, pickLocalizedText(type.description, locale))),
|
|
56
|
+
!hideButton &&
|
|
57
|
+
(renderLink ? (renderLink({
|
|
58
|
+
href,
|
|
59
|
+
className: buttonClassName,
|
|
60
|
+
children: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
61
|
+
seeClassesText,
|
|
62
|
+
" ",
|
|
63
|
+
react_1.default.createElement(lucide_react_1.ArrowRight, null))),
|
|
64
|
+
})) : (react_1.default.createElement("a", { href: href, className: buttonClassName },
|
|
65
|
+
seeClassesText,
|
|
66
|
+
" ",
|
|
67
|
+
react_1.default.createElement(lucide_react_1.ArrowRight, null)))))));
|
|
68
|
+
})));
|
|
69
|
+
};
|
|
70
|
+
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
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;AAE5D;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;GAEG;AACH,cAAc,SAAS,CAAC"}
|
|
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;AAE5D;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACrF,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");
|