You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

nuxt-telegram-miniapps

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-telegram-miniapps

This is an experiment in building a library of Telegram web application interface components with Tailwind CSS. All components inherit the design concept of Telegram for Android and partially Telegram for iOS, but do not try to match it exactly.

0.0.1-test9
latest
npmnpm
Version published
Weekly downloads
1
Maintainers
0
Weekly downloads
 
Created
Source

Nuxt Telegram Miniapps UI Kit

This is an experiment in building a library of Telegram web application interface components with Tailwind CSS. All components inherit the design concept of Telegram for Android and partially Telegram for iOS, but do not try to match it exactly.

⚠️ Please do not use this library in real projects until the first stable version is published. Breaking changes may occur without prior notice!

Installation

npm install -D nuxt-telegram-webapps

Note: This also installs required nuxt modules:

  • @nuxtjs/tailwindcss
  • @nuxtjs/google-fonts
  • nuxt-icon
  • @vueuse/nuxt

Usage

This component library is Nuxt Layer. To use it, just add the extends setting.

// nuxt.config.ts
export default defineNuxtConfig({
  extends: [
    'nuxt-telegram-miniapps',
  ]
})

Then create a page that is supposed to be a web application or place the web application components in the app.vue. It's recommended to place all components inside helper component TgContent.

<template>
  <TgContent>
    <TgSection>
      <TgCell title="Some title" />
    </TgSection>
  </TgContent>
</template>

Components

Image 1

TgSection

A component within which you can place TgCell`s groups or any content block of a web application

Props

NameTypeDescription
titlestringThe panel title
contentbooleanAdds paddings inside section, use if no cells inside
insetbooleanAdds margins around the section (automatically on iOS and macOS)
<!-- Section with cells -->
<TgSection title="Section title">
  <TgCell title="Cell 1" />
  <TgCell title="Cell 2" />
</TgSection>

<!-- Section with content -->
<TgSection title="Section title" content>
  <p>Some section content</p>
</TgSection>

Sections

TgCell

This is the main component of the menu. It automatically sets paddings, icon positioning, colors and dividers.

Props

NameTypeDescription
titlestringMain text of the cell
descriptionstringFaded small text or hint
subtitlestringNot faded small text, positioned before description
iconstringName of the icon (look: https://icones.js.org/)
line-clampstringLine clamp of the subtitle and description
colorstringCan be default, link, danger
icon-colorstringName of the color from those in the Tailwind set, or any CSS value
borderbooleanDetermines whether to show the border at the bottom
appendBorderbooleanWhether to show a border to the left of append

If the icon option is used, the icon will be displayed differently depending on the platform. On iOS and macOS the icon will be placed inside a colored square (don't forget to set icon-color), while on other platforms it will be displayed without a square and will inherit the system hint color.

If you want to control the display of the icon yourself, use the prepend slot and the TgIconBox component.

Slots

NameDescription
defaultYou can add any content you want to the cell
prependPlaces the content to the left of the main content, usually there is an icon there
appendPlaces the content to the right of the main content
<!-- Simple cell -->
<TgCell title="Some title" description="Some description" />

<!-- Cell with content -->
<TgCell>
  <p>Some content inside the cell</p>
</TgCell>

<!-- Cell with slots -->
<TgCell title="Some title" description="Some description">
  <template #icon>
    <TgIconBox icon="material-symbols:qr-code" />
  </template>
  <template #right>
    <TgButton size="sm">Button</TgButton>
  </template>
</TgCell>

TgButton

This is just button, not something special 💁‍♂️ It is used to trigger some actions

Props

NameTypeDescription
colorstringMay be primary or danger
typestringMay be button, submit or reset
tostringVue-Router route location
hrefstringExternal link
disabledbooleanDisabled state
relstringRel attribute
targetstringTarget attribute
sizestringMay be sm, md, lg or xl
textbooleanSet true if you want to make button look like link
iconstringThe name of the icon (look: https://icones.js.org/)

TgIconBox

A component to display an icon inside a circle or rectangle with rounded corners. The icon can be replaced by text

Props

NameTypeDescription
iconstringThe name of the icon (look: https://icones.js.org/)
textstringText to display instead of an icon
roundbooleanDisplay a circle or rectangle box
sizestringMay be sm, md, lg or xl
colorstringName of the color from those in the Tailwind set, or any CSS value
backgroundColorstringIcon box (background) color

You can place the TgIconBox in the icon slot of the TgCell component:

<TgCell title="Some title" description="Some description">
  <template #icon>
    <TgIconBox icon="material-symbols:qr-code" />
  </template>
</TgCell>

TgInput

Just input without borders

Props

NameTypeDescription
v-model:valuestringInput text
placeholderstringPlaceholder text
<TgSection title="Section title" content>
  <TgInput v-model:value="input" />
</TgSection>

Platforms

If you want to test the appearance on different platforms, use the usePlatform compsable in the app.vue file or in the miniapp page by passing the 'ios' or 'android' parameter to it and reloading the page. This is for testing and debugging purposes and may change in the future.

FAQs

Package last updated on 10 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts