• Stars
    star
    335
  • Rank 125,904 (Top 3 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Polymorpheus is a tiny library for polymorphic templates in Angular.

Polymorpheus

npm version Coverage Status angular-open-source-starter telegram chat

Polymorpheus is a tiny library for polymorphic templates in Angular.

It is 1 KB gzip, dependency free and allows you to make pretty cool things.

Polymorpheus

What does it do?

It abstracts over different ways of view customization in Angular with one simple structural directive:

<ng-container *polymorpheusOutlet="content as text; context: context">
    {{text}}
</ng-container>

Content accepts:

  • primitives like number or string
  • functions that take context as argument and return a primitive
  • templates that get instantiated with given context
  • components that would get context injected through DI

Context is optional when you need your content to adapt to the situation

How to use it?

Typical use case would be a component that accepts visual customization and defines context by itself. Say a menu list where you can configure how each item should look like by passing a template. And context would be item itself and, for example, whether it is focused or not.

Please see extensive demo (wait for packages to install and run npm start).

You can also read about this concept in detail.

Accessing context in dynamic component

If you use component content you can inject context with POLYMORPHEUS_CONTEXT token.

Important! This object is live so if you change it, your component will not be recreated:

@Component({
  template: '{{context.active}}`, // <-- this will automatically update
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MyComponent {
  constructor(
    @Inject(POLYMORPHEUS_CONTEXT) readonly context: { active: boolean }
  ) {}
}

Adding type to template context

You can use polymorpehus directive to add type to template context:

readonly context!: { $implicit: number };
<ng-template #template="polymorpheus" [polymorpheus]="context" let-item>
    {{ item.toFixed(2) }} <-- type 'number'
</ng-template>

Open-source

Do you also want to open-source something, but hate the collateral work? Check out this Angular Open-source Library Starter we’ve created for our projects. It got you covered on continuous integration, pre-commit checks, linting, versioning + changelog, code coverage and all that jazz.

Core team

Alex Inkin
Alex Inkin
Roman Sedov
Roman Sedov

ng-polymorpheus is a part of Taiga UI libraries family which is backed and used by a large enterprise. This means you can rely on timely support and continuous development.

More Repositories

1

taiga-ui

Angular UI Kit and components library for awesome people
TypeScript
2,658
star
2

career

Информация о внутренней кухне Тинькофф, включая подготовку к собеседованию
745
star
3

ng-web-apis

A set of common utils for consuming Web APIs with Angular
TypeScript
609
star
4

invest-openapi

Документация для Тинькофф Инвестиции OpenApi
HTML
457
star
5

investAPI

HTML
393
star
6

invest-python

Tinkoff Invest Python gRPC client
Python
309
star
7

maskito

Collection of libraries to create an input mask which ensures that user types value according to predefined format.
TypeScript
270
star
8

angular-open-source-starter

This is a starter project for creating open-source libraries for Angular. It is a full fledged Angular workspace with demo application and easy library addition. It is designed to be used for open-sourcing libraries on Github and has everything you'd need ready for CI, code coverage, SSR testing, StackBlitz demo deployment and more.
TypeScript
252
star
9

ng-event-plugins

This is an Angular library for optimizing performance sensitive events and declarative preventDefault, stopPropagation and capture phase listeners.
TypeScript
233
star
10

tramvai

A modular framework for universal JS applications
TypeScript
230
star
11

invest-openapi-js-sdk

TypeScript
211
star
12

utils.js

Fast, small and purely functional utility library
TypeScript
179
star
13

invest-openapi-java-sdk

Java
167
star
14

kora

Java
167
star
15

invest-openapi-go-sdk

Go
153
star
16

Nginx-builder

A tool to build deb or rpm package of required Nginx version from the source code, with the ability to connect third-party modules. Nginx parameters are set in the yaml configuration file.
Python
153
star
17

invest-robot-contest

Конкурс разработчиков торговых роботов на API Тинькофф Инвестиций
144
star
18

ng-morph

Code mutations in your project or schematics were never easier than now.
TypeScript
124
star
19

linters

Tinkoff ESlint, Stylelint and Prettier linter configurations
JavaScript
124
star
20

micro-sentry

Tiny Sentry client with idiomatic wrapper for Angular
TypeScript
117
star
21

libvirt-exporter

Prometheus metrics exporter for libvirt.
Go
105
star
22

invest-openapi-csharp-sdk

C#
100
star
23

microzord

Simple and powerful Micro Frontends framework
TypeScript
93
star
24

phobos

Efficient and expressive XML data-binding library for Scala
Scala
91
star
25

stapp

Modular state and side-effects management for microfrontends
TypeScript
90
star
26

jira-helper

Jira Helper - adds visual elements for swimlanes, a button for adding a task description template.
JavaScript
87
star
27

ng-dompurify

Inclusive Angular API for DOMPurify
TypeScript
85
star
28

invest-api-java-sdk

Tinkoff Invest API Java SDK
Java
74
star
29

overhave

Web-framework for BDD: scalable, configurable, easy to use, based on Flask Admin and Pydantic.
JavaScript
71
star
30

gatling-kafka-plugin

Plugin for support Kafka in Gatling
Scala
62
star
31

tinkoff-request

Modular lightweight request library extendable by plugins.
TypeScript
60
star
32

Horarium

Horarium is the .Net library to manage background jobs
C#
56
star
33

voicekit-examples

Examples on how to use Tinkoff Voicekit
C#
55
star
34

mockingbird

Flexible mock server
Scala
55
star
35

invest-api-csharp-sdk

C#
51
star
36

data-detective

Data catalog for everything in your company
Python
50
star
37

QVisual

Tinkoff tool to control quality by visual testing
Java
48
star
38

angular-contenteditable-accessor

This accessor allows you to use Angular forms with contenteditable elements with ease. It has zero dependencies, other than Angular itself as peer and works with Angular 4+ in all modern browsers, including Internet Explorer 11
TypeScript
46
star
39

eclair

Java Spring library for declarative logging
Java
41
star
40

invest-api-go-sdk

SDK для работы с API Тинькофф Инвестиций
Go
41
star
41

aerospike-scala

Typesafe DSL for work with Aerospike Database
Scala
40
star
42

perfectum

A set of tools for working with project performance
TypeScript
40
star
43

cachalot

Cache manager for nodejs with support different cache strategies
TypeScript
39
star
44

gatling-picatinny

Library with a bunch of usefull functions that extend Gatling DSL and make your performance better
Scala
37
star
45

muffin

Mattermost API v4 Client for Scala
Scala
36
star
46

shared-library-webpack-plugin

Webpack plugin for library sharing at runtime between applications
TypeScript
36
star
47

asterisk-voicekit-modules

Non-blocking Asterisk modules for accessing VoiceKit services for speech recognition and speech synthesis.
Shell
35
star
48

dm-knowledgebase

База знаний профессии Деливери менеджер https://tinkoff.github.io/dm-knowledgebase/
JavaScript
34
star
49

go-course-for-students

HTML
33
star
50

gatling-amqp-plugin

Plugin for support performance testing with AMQP in Gatling (3.7.x)
Scala
33
star
51

camunda-delegator-lib

This project provides declarative camunda delegates for Spring based application
Kotlin
32
star
52

Allure.XUnit

Allure.XUnit is a library for displaying xunit .NET Core and .NET 5 tests in Allure reports.
C#
30
star
53

neptune

Test automation framework
Java
29
star
54

gradle-jarjar

Plugin for gradle which allows you to repackage jar-libraries with different package names using JarJar tool
Groovy
28
star
55

pvm

TypeScript
28
star
56

sage-community

Shell
28
star
57

react-styling-hoc

Механизм темизации для React-компонентов, написанных с использованием CSS модулей.
JavaScript
26
star
58

react-render-logger

Simple util for log component updates
JavaScript
24
star
59

uconfig

Lightweight, header-only, C++17 configuration library
C++
22
star
60

react-lazy-hydration-render

TypeScript
22
star
61

stream-client

Lightweight, header-only, Boost-based socket pool library
C++
22
star
62

gatling-template.g8

A Giter8 template for gatling performance test project
Scala
22
star
63

gatling-jdbc-plugin

Simple gatling plugin for JDBC
Scala
21
star
64

argus

GitHub App for screenshots tests in CI
TypeScript
18
star
65

invest-js

TypeScript
18
star
66

ScalaDatabase

Scala Database wrapper based on JDBC
Scala
17
star
67

navigation-skeleton

This component allows you to show skeletons of pages during navigation process.
TypeScript
17
star
68

Ogam3

Data transfer protocol based on a lightweight implementation of Scheme programming language written on C# for .NET enterprise development.
C#
14
star
69

ISA

Information Search Assistant
C#
13
star
70

voicekit_client_python

Tinkoff Voicekit Python client
Python
12
star
71

checkinx-utils

DB execution plan asserts
Kotlin
11
star
72

swagger-types-generator

generate typescript types using a swagger schema
TypeScript
11
star
73

oolong

Oolong - compile-time query generation for document stores
Scala
10
star
74

uri-template

URI Templates expansion and reverse-matching for C++
C++
9
star
75

server-request-timer

A library for analyzing request execution
TypeScript
9
star
76

tui-editor

Rich text editor extension with related Taiga UI components https://tinkoff.github.io/tui-editor
TypeScript
7
star
77

mbclient

Message Broker Client/Server
TypeScript
6
star
78

tui-ngrx-forms-adapter

TypeScript
6
star
79

deimos

Scala
6
star
80

business-openapi

Репозиторий для обратной связи по Tinkoff Business OpenApi
6
star
81

tinkoff-id

HTML
5
star
82

cassandra-ansible-role

Cassandra ansible role with custom libs, backups, and other things
Jinja
3
star
83

tokenizer

TypeScript
3
star
84

sbt-schema-registry-plugin

Sbt plugin for download schemas from schema registry
Scala
3
star
85

tinkoff-asdk-windows

Tinkoff Acquiring SDK for Windows
C#
3
star
86

gatling-samples

Samples gatling scripts with plugins
Scala
3
star
87

receipt2vec

Tool for feature extracting from receipts from Russian stores
Python
3
star
88

AllurePlugin.emceeplugin

Swift
2
star
89

dolyamesdk-ios

Dolyame SDK for iOS
HTML
2
star
90

api_asdk

Interactive API documentation on reDOC for Acquiring SDK
HTML
2
star
91

react-pixi-racing-game

TypeScript
2
star
92

logrus-sage-formatter

Go
1
star
93

tinkoff.github.io

JavaScript
1
star
94

github-analytics

An application to see various charts and stats on GitHub repositories
TypeScript
1
star
95

slack-pr-bot

C#
1
star
96

xk6-output-error

A k6 extension for add more information into StdErr
Go
1
star
97

voicekit-docs

1
star