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

tailwindcss-turbo-native

v0.0.1

Published

A plugin for Tailwind CSS v3.0+ that provides utilities for handling turbo-native applications.

Downloads

3

Readme

tailwindcss-turbo-native

A plugin for Tailwind CSS v3.0+ that provides utilities for handling turbo-native applications.

Installation

Install the plugin from npm:

npm install tailwindcss-turbo-native

Tailwind

Then add the plugin to your tailwind.config.js file:

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('tailwindcss-turbo-native'),
    // ...
  ],
}

Rails

Your application.html.erb should conditionally render your chosen data tags to the page's html tag:

<html
  <%= 'data-turbo-native-android' if turbo_native_android_app? %>
  <%= 'data-turbo-native-ios' if turbo_native_ios_app? %>
>

The following helpers should also be added to a app/helpers/turbo_native_helper.rb file. The exact regex matching for iOS is configured by default, you might need to explicitly configure your iOS app to explicitly add Turbo Native iOS to the application's userAgent.

module TurboNativeHelper
  def turbo_native_ios_app?
    request.user_agent.to_s.match?(/Turbo Native iOS/)
  end

  def turbo_native_android_app?
    request.user_agent.to_s.match?(/Turbo Native Android/)
  end
end

iOS

For example by using the following WKWebViewConfiguration

import Foundation
import WebKit

enum WebViewPool {
    static var shared = WKProcessPool()
}

extension WKWebViewConfiguration {
    static var appConfiguration: WKWebViewConfiguration {
        let userAgent = "Turbo Native iOS"

        let configuration = WKWebViewConfiguration()
        configuration.processPool = WebViewPool.shared
        configuration.applicationNameForUserAgent = userAgent
        configuration.defaultWebpagePreferences?.preferredContentMode = .mobile

        return configuration
    }
}

Android

Android turbo native apps already include the Turbo Native Android in their userAgents so no additional configuration should be neccesary.

Usage

The following body would render differently in each of the preceding HTML tags.

<h2 class="text-green-500">I am green on all platforms</h2>
<h2 class="web:text-green-500">I am green on web platforms</h2>
<h2 class="not-web:text-green-500">I am green on non-web platforms</h2>
<h2 class="ios:text-green-500">I am green on iOS platforms</h2>
<h2 class="not-ios:text-green-500">I am green on non-iOS platforms</h2>
<h2 class="android:text-green-500">I am green on android platforms</h2>
<h2 class="not-android:text-green-500">I am green on non-android platforms</h2>

Web

<html>
  <!-- # No additional attribute gets applied to the html tag-->
  <h2 class="text-green-500">I am green on all platforms</h2>
  <h2 class="web:text-green-500">I am green on web platforms</h2>
  <h2 class="not-web:text-green-500">I am green on non-web platforms</h2>
  <h2 class="ios:text-green-500">I am green on iOS platforms</h2>
  <h2 class="not-ios:text-green-500">I am green on non-iOS platforms</h2>
  <h2 class="android:text-green-500">I am green on android platforms</h2>
  <h2 class="not-android:text-green-500">I am green on non-android platforms</h2>
</html>

Web Platform

Android

<html data-turbo-native-android>
  <h2 class="text-green-500">I am green on all platforms</h2>
  <h2 class="web:text-green-500">I am green on web platforms</h2>
  <h2 class="not-web:text-green-500">I am green on non-web platforms</h2>
  <h2 class="ios:text-green-500">I am green on iOS platforms</h2>
  <h2 class="not-ios:text-green-500">I am green on non-iOS platforms</h2>
  <h2 class="android:text-green-500">I am green on android platforms</h2>
  <h2 class="not-android:text-green-500">I am green on non-android platforms</h2>
</html>

Android Platform

iOS

<html data-turbo-native-ios>
  <h2 class="text-green-500">I am green on all platforms</h2>
  <h2 class="web:text-green-500">I am green on web platforms</h2>
  <h2 class="not-web:text-green-500">I am green on non-web platforms</h2>
  <h2 class="ios:text-green-500">I am green on iOS platforms</h2>
  <h2 class="not-ios:text-green-500">I am green on non-iOS platforms</h2>
  <h2 class="android:text-green-500">I am green on android platforms</h2>
  <h2 class="not-android:text-green-500">I am green on non-android platforms</h2>
</html>

iOS Platform

Configuration

By default we ship with the following configured values:

"turboNativeCustomDataAttributes": {
    "android": "data-turbo-native-android",
    "ios": "data-turbo-native-ios"
}

| Configuration Variable | Default Value | Info | | ----------------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------- | | turboNativeCustomDataAttributes.android | data-turbo-native-android | Configures the data attribute that should be applied to your HTML tag for android rendering | | turboNativeCustomDataAttributes.ios | data-turbo-native-ios | Configures the data attribute that should be applied to your HTML tag for iOS rendering |

You can configure which data attributes you use to for dynamic rendering in your turbo native application by editing your tailwind.config.js file:

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      turboNativeCustomDataAttributes: {
        ios: 'data-android',
        android: 'data-ios',
      },
    },
  },
}

This override would require you to render your markup as follows for Web, iOS, and Android.

Web

<html>
  <!-- # No additional attribute -->
  <!-- rest of your markup to abide by tailwindcss-turbo-native rules  -->
</html>

iOS

<html data-ios>
  <!-- rest of your markup to abide by tailwindcss-turbo-native rules where iOS is rendered  -->
</html>

Android

<html data-android>
  <!-- rest of your markup to abide by tailwindcss-turbo-native rules where android is rendered -->
</html>