npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jagaad/vue-hubspot-form

v2.2.3

Published

A Vue wrapper for HubSpot Forms

Downloads

1,226

Readme

HubSpot Vue Form

A Vue wrapper for HubSpot Forms

Usage

npm install @jagaad/vue-hubspot-form

Component usage:

<script setup>
import HubspotForm from '@jagaad/vue-hubspot-form';
</script>
<template>
	<HubspotForm
		@ready="onReady"
		:options="options"
		:fallback="fallback"
		:error="error"
	></HubspotForm>
</template>

Hook usage:

<script setup>
import { useHubspotForm } from '@jagaad/vue-hubspot-form';
const { difRef, isLoading, isError } = useHubspotForm(options, onReady)
</script>
<template>
	<div v-if="!(isLoading || isError)" ref="divRef">
	<component v-if="isLoading" :is="fallback" />
	<component v-if="isError" :is="error" />
</template>

All examples make use partially of code blocks defined below

<template>
	<HubspotForm
		@ready="onReady"
		:options="options"
		:fallback="fallback"
		:error="error"
	/>
</template>
<template>
	<HubspotForm
		:onReady="onReady"
		:options="options"
		:fallback="fallback"
		:error="error"
	/>
</template>
import { CreateOptions } from '@jagaad/vue-hubspot-form';

// these values are fake, add your own
const options: CreateOptions = {
	// ...
	// Read the official docs for more info
	cssRequired: `.hubspot-link__container { display: none }`,
	// ...
};
import { Payload } from '@jagaad/vue-hubspot-form';

function onReady({ iframeDocument: doc }: Payload) {
	const element = doc.createElement('style');
	const styles = `.hubspot-link__container { display: none }`;
	element.appendChild(doc.createTextNode(styles));
	doc.head.appendChild(element);
}
import jss, { Rule } from 'jss';

jss.use({
	// this will make JSS to use selectors as names
	onCreateRule(name, _decl, options) {
		options.selector = name;
		return null as unknown as Rule;
	},
});

const styleSheet = jss.createStyleSheet({
	'.hubspot-link__container': {
		display: 'none',
	},
});

const options = {
	// ...
	cssRequired: styleSheet.toString(),
};

Options:

import { CreateOptions } from '@jagaad/vue-hubspot-form';

// these values are fake, add your own
const options: CreateOptions = {
	region: 'eu1',
	portalId: '83991272',
	formId: '25f1e214-1236-45c3-810m-d8dk31736c72',
	// ...
};

On Ready callback:

import { Payload } from '@jagaad/vue-hubspot-form';

const onReady = (payload: Payload) => console.log(payload);

Fallback Components:

import { defineComponent } from 'vue';

// Loading Component
const fallback = defineComponent({
	/* ... */
});
// Error Component
const error = defineComponent({
	/* ... */
});

Contributing

git clone [email protected]:jagaad/vue-hubspot-form.git
cd vue-hubspot-form
npm install
  • Create a copy of .env file to .env.local
  • Adjust .env.local to your HubSpot values
npm run dev

Links

  • https://developers.hubspot.com/docs/cms/building-blocks/forms
  • https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options
  • https://github.com/escaladesports/react-hubspot-form/blob/master/src/index.js

Vue 3 + Typescript + Vite

This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.

Recommended IDE Setup

Type Support For .vue Imports in TS

Since TypeScript cannot handle type information for .vue imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in .vue imports (for example to get props validation when using manual h(...) calls), you can enable Volar's .vue type support plugin by running Volar: Switch TS Plugin on/off from VSCode command palette.