@neo4j-ndl/react
Version:
React implementation of Neo4j Design System
81 lines (70 loc) • 2.75 kB
JavaScript
"use strict";
/**
*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.LANGUAGE_SYNTAX_HIGHLIGHTING_EXAMPLES = exports.LONG_CODE_EXAMPLE = exports.SHORT_CODE_EXAMPLE = void 0;
// Short examples - ideal for basic demos and small displays
exports.SHORT_CODE_EXAMPLE = `// validate.ts
import { z } from "zod";
// creating a schema for strings
const mySchema = z.string();
// parsing
mySchema.parse("tuna"); // => "tuna"
mySchema.parse(12); // => throws ZodError
// "safe" parsing (doesn't throw error if validation fails)
mySchema.safeParse("tuna"); // => { success: true; data: "tuna" }
mySchema.safeParse(12); // => { success: false; error: ZodError }`;
exports.LONG_CODE_EXAMPLE = `// dates.js
import { format, formatDistance, formatRelative, subDays } from 'date-fns'
format(new Date(), "'Today is a' eeee")
//=> "Today is a Tuesday"
formatDistance(subDays(new Date(), 3), new Date(), { addSuffix: true })
//=> "3 days ago"
formatRelative(subDays(new Date(), 3), new Date())
//=> "last Friday at 7:26 p.m."
// validate.ts
import { z } from "zod";
// creating a schema for strings
const mySchema = z.string();
// parsing
mySchema.parse("tuna"); // => "tuna"
mySchema.parse(12); // => throws ZodError
// "safe" parsing (doesn't throw error if validation fails)
mySchema.safeParse("tuna"); // => { success: true; data: "tuna" }
mySchema.safeParse(12); // => { success: false; error: ZodError }`;
exports.LANGUAGE_SYNTAX_HIGHLIGHTING_EXAMPLES = {
CYPHER: `MATCH (n:Person)-[r]->(m:Person {age: 20})
WITH m, n
ORDER BY m.name ASC LIMIT 3
RETURN collect(n.name) AS names, TRUE as bool, 1 as num, "string" as str`,
JSON: `{
"name": "John Doe",
"age": 30,
"email": "john.doe@example.com"
}`,
TYPESCRIPT: `function greetUser(name: string): string {
return \`Hello, \${name}! Welcome to Needle Design System.\`;
}
const user = "John Doe";
const message = greetUser(user);
console.log(message);`,
};
//# sourceMappingURL=example-code-snippets.js.map