Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/bin/commands/init.js
  • Loading branch information
itsJohnnyGrid committed Feb 20, 2025
2 parents c7ced3d + 74d1f93 commit 8afe0a2
Show file tree
Hide file tree
Showing 26 changed files with 514 additions and 225 deletions.
2 changes: 2 additions & 0 deletions .storybook/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ body {
.light .sbdocs .sbdocs-content > h3,
.light .sbdocs .sbdocs-content > .sb-anchor > h3,
.light .sbdocs .sbdocs-content > .sb-anchor > p,
.light .sbdocs .sbdocs-content > ul > li,
.light .sbdocs .sbdocs-content > p,
.light .sbdocs .sbdocs-content > table th,
.light .sbdocs .sbdocs-content > table td {
Expand All @@ -79,6 +80,7 @@ body {
.dark .sbdocs .sbdocs-content > h3,
.dark .sbdocs .sbdocs-content > .sb-anchor > h3,
.dark .sbdocs .sbdocs-content > .sb-anchor > p,
.dark .sbdocs .sbdocs-content ul > li,
.dark .sbdocs .sbdocs-content > p,
.dark .sbdocs .sbdocs-content > table th,
.dark .sbdocs .sbdocs-content > table td {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vueless",
"version": "0.0.790",
"version": "0.0.796",
"license": "MIT",
"description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
"keywords": [
Expand Down
9 changes: 6 additions & 3 deletions src/bin/commands/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ async function modifyCreatedComponent(destPath, componentName, newComponentName)
const destFiles = await getDirFiles(destPath, "");
const storybookId = await getStorybookId();

const componentFileName = `${componentName}.vue`;
const newComponentFileName = `${newComponentName}.vue`;

for await (const filePath of destFiles) {
const fileContent = await readFile(filePath, "utf-8");

Expand All @@ -78,13 +81,13 @@ async function modifyCreatedComponent(destPath, componentName, newComponentName)
storyLines[storyIdIndex] = ` id: "${storybookId}",`;
storyLines[storyTitleIndex] = ` title: "Custom / ${newComponentName}",`;
storyLines[storyComponentImportIndex] =
`import ${newComponentName} from "../${newComponentName}.vue"`;
`import ${newComponentName} from "../${newComponentFileName}"`;

updatedContent = storyLines.join("\n").replaceAll(componentName, newComponentName);
}

if (targetPath.endsWith(`${componentName}.vue`)) {
targetPath = targetPath.replace(componentName, newComponentName);
if (targetPath.endsWith(componentFileName)) {
targetPath = targetPath.replace(componentFileName, newComponentFileName);

await rename(filePath, targetPath);
}
Expand Down
18 changes: 17 additions & 1 deletion src/bin/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import { cwd } from "node:process";
import path from "node:path";
import { writeFile } from "node:fs/promises";
import { existsSync } from "node:fs";
import { writeFile, rename } from "node:fs/promises";
import { styleText } from "node:util";

import { DEFAULT_VUELESS_CONFIG_CONTENT } from "../constants.js";
Expand All @@ -24,6 +25,21 @@ export async function vuelessInit(options) {
ext: fileExt,
});

if (existsSync(formattedDestPath)) {
const timestamp = new Date().valueOf();
const renamedTarget = `${VUELESS_CONFIG_FILE_NAME}-backup-${timestamp}${fileExt}`;

await rename(formattedDestPath, renamedTarget);

const warnMessage = styleText(
"yellow",
// eslint-disable-next-line vue/max-len
`Current Vueless config backed into: '${path.basename(renamedTarget)}' folder. Don't forget to remove it before commit.`,
);

console.warn(warnMessage);
}

await writeFile(formattedDestPath, DEFAULT_VUELESS_CONFIG_CONTENT, "utf-8");

const successMessage = styleText(
Expand Down
6 changes: 4 additions & 2 deletions src/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

/* eslint-disable no-console */

import { styleText } from "node:util";

import { commands } from "./commands/index.js";

import { DEFAULT_EXIT_CODE, FAILURE_CODE } from "../constants.js";
Expand All @@ -16,9 +18,9 @@ try {
if (command in commands) {
commands[command](options);
} else {
throw new Error(`There is no such command: ${command}`);
throw new Error(styleText("red", `There is no such command: ${command}`));
}
} catch (error) {
console.error(error.message);
console.error(styleText("red", error.message));
process.exit(error.code || FAILURE_CODE);
}
48 changes: 30 additions & 18 deletions src/directives/tooltip/vTooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { merge } from "lodash-es";
import { vuelessConfig } from "../../utils/ui.ts";
import { isCSR, isSSR } from "../../utils/helper.ts";

import type { DefaultProps } from "tippy.js";
import type { DefaultProps, Instance as TippyInstance, Props as TippyProps } from "tippy.js";
import type {
TippyTargetElement,
DirectiveBindingContent,
Expand Down Expand Up @@ -36,19 +36,7 @@ function onMounted(
): void {
if (isSSR) return;

if (typeof bindings.value === "string" && bindings.value.length) {
tippy(el, merge(settings, { content: bindings.value }));

return;
}

if (
typeof bindings.value !== "string" &&
bindings.value.content &&
String(bindings.value.content).length
) {
tippy(el, merge(settings, bindings.value || {}));
}
setUpTippy(el, bindings.value);
}

function onUpdated(el: TippyTargetElement, bindings: DirectiveBindingContent): void;
Expand All @@ -57,15 +45,15 @@ function onUpdated(
el: TippyTargetElement,
bindings: DirectiveBindingProps | DirectiveBindingContent,
): void {
if (!el._tippy || isSSR) return;
if (isSSR) return;

if (typeof bindings.value === "string") {
el._tippy.setProps(merge(settings, { content: bindings.value }));
if (!el._tippy) {
setUpTippy(el, bindings.value);

return;
}

el._tippy.setProps(merge(settings, bindings.value || {}));
updateTippyProps(el._tippy, bindings.value);
}

function onUnmounted(el: TippyTargetElement) {
Expand All @@ -74,6 +62,30 @@ function onUnmounted(el: TippyTargetElement) {
el._tippy.destroy();
}

function setUpTippy(el: HTMLElement, props: string | TippyProps) {
if (typeof props === "string" && props.length) {
tippy(el, merge(settings, { content: props }));

return;
}

if (typeof props !== "string" && props.content && String(props.content).length) {
tippy(el, merge(settings, props || {}));
}
}

function updateTippyProps(tippyInstance: TippyInstance | undefined, props: string | TippyProps) {
if (!tippyInstance || isSSR) return;

if (typeof props === "string") {
tippyInstance.setProps(merge(settings, { content: props }));

return;
}

tippyInstance.setProps(merge(settings, props || {}));
}

export default {
mounted: onMounted,
updated: onUpdated,
Expand Down
1 change: 0 additions & 1 deletion src/ui.form-input-rating/UInputRating.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ defineOptions({ inheritAttrs: false });
const props = withDefaults(defineProps<Props>(), {
...getDefaults<Props, Config>(defaultConfig, COMPONENT_NAME),
label: "",
});
const emit = defineEmits([
Expand Down
Loading

0 comments on commit 8afe0a2

Please sign in to comment.