├── .browserslistrc ├── .editorconfig ├── .gitignore ├── .prettierrc ├── README.md ├── angular.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.ts │ ├── app.module.ts │ └── components │ │ ├── communication-preference │ │ ├── communication-preference.component.ts │ │ └── communication-preference.module.ts │ │ ├── country-selector │ │ ├── country-selector.component.ts │ │ └── country-selector.module.ts │ │ └── footer │ │ └── footer.component.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.scss ├── styles │ └── partials │ │ ├── _buttons.scss │ │ ├── _colors.scss │ │ └── _forms.scss └── test.ts ├── tailwind.config.js ├── tsconfig.app.json ├── tsconfig.json └── tsconfig.spec.json /.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | 16 | # IDEs and editors 17 | /.idea 18 | .project 19 | .classpath 20 | .c9/ 21 | *.launch 22 | .settings/ 23 | *.sublime-workspace 24 | 25 | # IDE - VSCode 26 | .vscode/* 27 | !.vscode/settings.json 28 | !.vscode/tasks.json 29 | !.vscode/launch.json 30 | !.vscode/extensions.json 31 | .history/* 32 | 33 | # misc 34 | /.sass-cache 35 | /connect.lock 36 | /coverage 37 | /libpeerconnection.log 38 | npm-debug.log 39 | yarn-error.log 40 | testem.log 41 | /typings 42 | 43 | # System Files 44 | .DS_Store 45 | Thumbs.db 46 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "printWidth": 120, 4 | "trailingComma": "all" 5 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NgCustomFormElements 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.1.1. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "ng-custom-form-elements": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "style": "scss" 11 | }, 12 | "@schematics/angular:application": { 13 | "strict": true 14 | } 15 | }, 16 | "root": "", 17 | "sourceRoot": "src", 18 | "prefix": "app", 19 | "architect": { 20 | "build": { 21 | "builder": "@angular-devkit/build-angular:browser", 22 | "options": { 23 | "outputPath": "dist/ng-custom-form-elements", 24 | "index": "src/index.html", 25 | "main": "src/main.ts", 26 | "polyfills": "src/polyfills.ts", 27 | "tsConfig": "tsconfig.app.json", 28 | "inlineStyleLanguage": "scss", 29 | "stylePreprocessorOptions": { 30 | "includePaths": [ 31 | "src/styles", 32 | "src/styles/partials" 33 | ] 34 | }, 35 | "assets": [ 36 | "src/favicon.ico", 37 | "src/assets" 38 | ], 39 | "styles": [ 40 | "src/styles.scss" 41 | ], 42 | "scripts": [] 43 | }, 44 | "configurations": { 45 | "production": { 46 | "budgets": [ 47 | { 48 | "type": "initial", 49 | "maximumWarning": "500kb", 50 | "maximumError": "1mb" 51 | }, 52 | { 53 | "type": "anyComponentStyle", 54 | "maximumWarning": "2kb", 55 | "maximumError": "4kb" 56 | } 57 | ], 58 | "fileReplacements": [ 59 | { 60 | "replace": "src/environments/environment.ts", 61 | "with": "src/environments/environment.prod.ts" 62 | } 63 | ], 64 | "outputHashing": "all" 65 | }, 66 | "development": { 67 | "buildOptimizer": false, 68 | "optimization": false, 69 | "vendorChunk": true, 70 | "extractLicenses": false, 71 | "sourceMap": true, 72 | "namedChunks": true 73 | } 74 | }, 75 | "defaultConfiguration": "production" 76 | }, 77 | "serve": { 78 | "builder": "@angular-devkit/build-angular:dev-server", 79 | "configurations": { 80 | "production": { 81 | "browserTarget": "ng-custom-form-elements:build:production" 82 | }, 83 | "development": { 84 | "browserTarget": "ng-custom-form-elements:build:development" 85 | } 86 | }, 87 | "defaultConfiguration": "development" 88 | }, 89 | "extract-i18n": { 90 | "builder": "@angular-devkit/build-angular:extract-i18n", 91 | "options": { 92 | "browserTarget": "ng-custom-form-elements:build" 93 | } 94 | }, 95 | "test": { 96 | "builder": "@angular-devkit/build-angular:karma", 97 | "options": { 98 | "main": "src/test.ts", 99 | "polyfills": "src/polyfills.ts", 100 | "tsConfig": "tsconfig.spec.json", 101 | "karmaConfig": "karma.conf.js", 102 | "inlineStyleLanguage": "scss", 103 | "assets": [ 104 | "src/favicon.ico", 105 | "src/assets" 106 | ], 107 | "styles": [ 108 | "src/styles.scss" 109 | ], 110 | "scripts": [] 111 | } 112 | } 113 | } 114 | } 115 | }, 116 | "defaultProject": "ng-custom-form-elements" 117 | } -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/ng-custom-form-elements'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-custom-form-elements", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "watch": "ng build --watch --configuration development", 9 | "test": "ng test" 10 | }, 11 | "private": true, 12 | "dependencies": { 13 | "@angular/animations": "~12.1.1", 14 | "@angular/common": "~12.1.1", 15 | "@angular/compiler": "~12.1.1", 16 | "@angular/core": "~12.1.1", 17 | "@angular/forms": "~12.1.1", 18 | "@angular/platform-browser": "~12.1.1", 19 | "@angular/platform-browser-dynamic": "~12.1.1", 20 | "@angular/router": "~12.1.1", 21 | "rxjs": "~6.6.0", 22 | "tslib": "^2.2.0", 23 | "zone.js": "~0.11.4" 24 | }, 25 | "devDependencies": { 26 | "@angular-devkit/build-angular": "~12.1.1", 27 | "@angular/cli": "~12.1.1", 28 | "@angular/compiler-cli": "~12.1.1", 29 | "@tailwindcss/forms": "^0.3.3", 30 | "@types/jasmine": "~3.6.0", 31 | "@types/node": "^12.11.1", 32 | "jasmine-core": "~3.7.0", 33 | "karma": "~6.3.0", 34 | "karma-chrome-launcher": "~3.1.0", 35 | "karma-coverage": "~2.0.3", 36 | "karma-jasmine": "~4.0.0", 37 | "karma-jasmine-html-reporter": "^1.5.0", 38 | "prettier": "^2.3.2", 39 | "tailwindcss": "^2.2.4", 40 | "typescript": "~4.3.2" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | 4 | const routes: Routes = []; 5 | 6 | @NgModule({ 7 | imports: [RouterModule.forRoot(routes)], 8 | exports: [RouterModule] 9 | }) 10 | export class AppRoutingModule { } 11 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 | 6 |
7 |
8 | 9 | 10 |
11 |
12 | 13 | 14 |
15 |
16 | 17 | 18 |
19 |
20 | 21 | 22 |
23 | 31 |
32 |
33 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | main { 2 | min-height: calc(100vh - 40px); 3 | } 4 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { FormBuilder, Validators } from '@angular/forms'; 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'], 7 | }) 8 | export class AppComponent { 9 | form = this.fb.group({ 10 | name: ['Adithya', [Validators.required]], 11 | github: ['https://github.com/AdiSreyaj', [Validators.required]], 12 | website: ['https://adi.so', [Validators.required]], 13 | server: ['IN', Validators.required], 14 | communications: [ 15 | [ 16 | { 17 | label: 'Marketing', 18 | modes: [ 19 | { 20 | name: 'Email', 21 | enabled: true, 22 | }, 23 | { 24 | name: 'SMS', 25 | enabled: false, 26 | }, 27 | ], 28 | }, 29 | { 30 | label: 'Product Updates', 31 | modes: [ 32 | { 33 | name: 'Email', 34 | enabled: true, 35 | }, 36 | { 37 | name: 'SMS', 38 | enabled: true, 39 | }, 40 | ], 41 | }, 42 | ], 43 | ], 44 | }); 45 | 46 | constructor(private fb: FormBuilder) { 47 | this.form.valueChanges.subscribe(console.info); 48 | } 49 | 50 | toggleServerDisable() { 51 | const server = this.form.get('server'); 52 | server?.disabled ? server.enable() : server?.disable(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 3 | import { BrowserModule } from '@angular/platform-browser'; 4 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 5 | import { AppRoutingModule } from './app-routing.module'; 6 | import { AppComponent } from './app.component'; 7 | import { CommunicationPreferenceModule } from './components/communication-preference/communication-preference.module'; 8 | import { CountrySelectorModule } from './components/country-selector/country-selector.module'; 9 | import { FooterComponent } from './components/footer/footer.component'; 10 | 11 | @NgModule({ 12 | declarations: [AppComponent, FooterComponent], 13 | imports: [ 14 | BrowserModule, 15 | AppRoutingModule, 16 | BrowserAnimationsModule, 17 | FormsModule, 18 | ReactiveFormsModule, 19 | CountrySelectorModule, 20 | CommunicationPreferenceModule, 21 | ], 22 | providers: [], 23 | bootstrap: [AppComponent], 24 | }) 25 | export class AppModule {} 26 | -------------------------------------------------------------------------------- /src/app/components/communication-preference/communication-preference.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, forwardRef, Provider } from '@angular/core'; 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; 3 | 4 | export interface CommunicationPreference { 5 | label: string; 6 | modes: { name: string; enabled: boolean }[]; 7 | } 8 | 9 | const COM_PREFERENCE_CONTROL_VALUE_ACCESSOR: Provider = { 10 | provide: NG_VALUE_ACCESSOR, 11 | useExisting: forwardRef(() => CommunicationPreferenceComponent), 12 | multi: true, 13 | }; 14 | 15 | @Component({ 16 | selector: 'app-communication-preference', 17 | template: `
18 | 38 |
`, 39 | providers: [COM_PREFERENCE_CONTROL_VALUE_ACCESSOR], 40 | styles: [ 41 | ` 42 | :host { 43 | width: 100%; 44 | } 45 | `, 46 | ], 47 | }) 48 | export class CommunicationPreferenceComponent implements ControlValueAccessor { 49 | options: CommunicationPreference[] = []; 50 | private onTouched!: Function; 51 | private onChanged!: Function; 52 | handleChange(itemIndex: number, modeIndex: number, change: any) { 53 | this.options[itemIndex].modes[modeIndex].enabled = change; 54 | this.onChanged(this.options); 55 | this.onTouched(); 56 | } 57 | 58 | writeValue(value: any): void { 59 | this.options = value; 60 | } 61 | registerOnChange(fn: any): void { 62 | this.onChanged = fn; 63 | } 64 | registerOnTouched(fn: any): void { 65 | this.onTouched = fn; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/app/components/communication-preference/communication-preference.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { NgModule } from '@angular/core'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { CommunicationPreferenceComponent } from './communication-preference.component'; 5 | 6 | @NgModule({ 7 | declarations: [CommunicationPreferenceComponent], 8 | imports: [CommonModule, FormsModule], 9 | exports: [CommunicationPreferenceComponent], 10 | }) 11 | export class CommunicationPreferenceModule {} 12 | -------------------------------------------------------------------------------- /src/app/components/country-selector/country-selector.component.ts: -------------------------------------------------------------------------------- 1 | import { animate, state, style, transition, trigger } from '@angular/animations'; 2 | import { Component, forwardRef, Provider } from '@angular/core'; 3 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; 4 | 5 | const COUNTRY_CONTROL_VALUE_ACCESSOR: Provider = { 6 | provide: NG_VALUE_ACCESSOR, 7 | useExisting: forwardRef(() => CountrySelectorComponent), 8 | multi: true, 9 | }; 10 | 11 | @Component({ 12 | selector: 'app-country-selector', 13 | template: ` 14 |
15 | 16 | 46 | 47 |
48 | `, 49 | providers: [COUNTRY_CONTROL_VALUE_ACCESSOR], 50 | styles: [ 51 | ` 52 | button { 53 | @apply outline-none transition-all duration-200; 54 | &:not(.selected) { 55 | @apply focus:ring focus:ring-primary focus:ring-2; 56 | } 57 | &:disabled { 58 | opacity: 0.7; 59 | } 60 | } 61 | .selected { 62 | @apply shadow-lg border-primary; 63 | } 64 | `, 65 | ], 66 | animations: [ 67 | trigger('selected', [ 68 | state('*', style({ opacity: 1, transform: 'scale(1)' })), 69 | state('void', style({ opacity: 0, transform: 'scale(0)' })), 70 | transition(':enter', animate('300ms ease-in-out')), 71 | transition(':leave', animate('300ms ease-in-out')), 72 | ]), 73 | ], 74 | }) 75 | export class CountrySelectorComponent implements ControlValueAccessor { 76 | countries = [ 77 | { code: 'IN', name: 'India' }, 78 | { code: 'US', name: 'United States' }, 79 | { code: 'GB-ENG', name: 'England' }, 80 | { code: 'NL', name: 'Netherlands' }, 81 | ]; 82 | selected!: string; 83 | disabled = false; 84 | private onTouched!: Function; 85 | private onChanged!: Function; 86 | 87 | selectCountry(code: string) { 88 | this.onTouched(); 89 | this.selected = code; 90 | this.onChanged(code); 91 | } 92 | 93 | writeValue(value: string): void { 94 | this.selected = value ?? 'IN'; 95 | } 96 | registerOnChange(fn: any): void { 97 | this.onChanged = fn; 98 | } 99 | registerOnTouched(fn: any): void { 100 | this.onTouched = fn; 101 | } 102 | setDisabledState(isDisabled: boolean) { 103 | this.disabled = isDisabled; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/app/components/country-selector/country-selector.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { NgModule } from '@angular/core'; 3 | import { CountrySelectorComponent } from './country-selector.component'; 4 | 5 | @NgModule({ 6 | declarations: [CountrySelectorComponent], 7 | imports: [CommonModule], 8 | exports: [CountrySelectorComponent], 9 | }) 10 | export class CountrySelectorModule {} 11 | -------------------------------------------------------------------------------- /src/app/components/footer/footer.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-footer', 5 | template: ` `, 73 | styles: [ 74 | ` 75 | :host { 76 | width: 100%; 77 | } 78 | `, 79 | ], 80 | }) 81 | export class FooterComponent {} 82 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adisreyaj/ng-custom-form-elements/3d9f7272edebba5d6a5be037196cffd937e1e228/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adisreyaj/ng-custom-form-elements/3d9f7272edebba5d6a5be037196cffd937e1e228/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Angular Custom Form Elements 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * IE11 requires the following for NgClass support on SVG elements 23 | */ 24 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 25 | 26 | /** 27 | * Web Animations `@angular/platform-browser/animations` 28 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 29 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 30 | */ 31 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 32 | 33 | /** 34 | * By default, zone.js will patch all possible macroTask and DomEvents 35 | * user can disable parts of macroTask/DomEvents patch by setting following flags 36 | * because those flags need to be set before `zone.js` being loaded, and webpack 37 | * will put import in the top of bundle, so user need to create a separate file 38 | * in this directory (for example: zone-flags.ts), and put the following flags 39 | * into that file, and then add the following code before importing zone.js. 40 | * import './zone-flags'; 41 | * 42 | * The flags allowed in zone-flags.ts are listed here. 43 | * 44 | * The following flags will work for all browsers. 45 | * 46 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 47 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 48 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 49 | * 50 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 51 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 52 | * 53 | * (window as any).__Zone_enable_cross_context_check = true; 54 | * 55 | */ 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by default for Angular itself. 59 | */ 60 | import 'zone.js'; // Included with Angular CLI. 61 | 62 | 63 | /*************************************************************************************************** 64 | * APPLICATION IMPORTS 65 | */ 66 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss/base'; 2 | @import 'tailwindcss/components'; 3 | @import 'tailwindcss/utilities'; 4 | 5 | * { 6 | margin: 0; 7 | padding: 0; 8 | box-sizing: border-box; 9 | } 10 | 11 | body * { 12 | font-family: 'Poppins', sans-serif; 13 | } 14 | @import 'colors'; 15 | @import 'forms'; 16 | @import 'buttons'; 17 | 18 | button:disabled { 19 | cursor: not-allowed; 20 | } 21 | -------------------------------------------------------------------------------- /src/styles/partials/_buttons.scss: -------------------------------------------------------------------------------- 1 | button.btn { 2 | @apply relative; 3 | @apply rounded-md; 4 | @apply cursor-pointer; 5 | @apply bg-none; 6 | @apply font-medium; 7 | @apply px-3 py-2; 8 | @apply text-sm; 9 | @apply border; 10 | @apply border-transparent; 11 | @apply focus:outline-none; 12 | @apply disabled:cursor-not-allowed; 13 | @apply focus:ring focus:ring-inset focus:ring-2; 14 | @apply focus:ring-offset-2; 15 | &.primary { 16 | @apply bg-primary; 17 | @apply text-white; 18 | @apply focus:ring-white focus:ring-offset-primary; 19 | } 20 | &.secondary { 21 | @apply bg-gray-200; 22 | @apply focus:ring-primary focus:ring-offset-gray-200; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/styles/partials/_colors.scss: -------------------------------------------------------------------------------- 1 | :root { 2 | --primary: hsl(160, 84%, 34%); 3 | 4 | } -------------------------------------------------------------------------------- /src/styles/partials/_forms.scss: -------------------------------------------------------------------------------- 1 | .form-group { 2 | @apply flex flex-col; 3 | @apply items-start; 4 | @apply pb-6; 5 | @apply relative; 6 | & > label { 7 | @apply text-gray-700; 8 | @apply mb-1; 9 | @apply text-base; 10 | @apply font-medium; 11 | } 12 | 13 | textarea { 14 | @apply focus:ring-1; 15 | @apply focus:ring-primary; 16 | resize: none; 17 | &:disabled { 18 | @apply text-gray-400; 19 | } 20 | } 21 | 22 | input[type='checkbox'], 23 | input[type='radio'] { 24 | @apply text-primary; 25 | @apply cursor-pointer; 26 | @apply rounded-md; 27 | @apply focus:ring-primary; 28 | } 29 | } 30 | 31 | [type='text'], 32 | [type='email'], 33 | [type='url'], 34 | [type='password'], 35 | [type='number'], 36 | [type='date'], 37 | [type='datetime-local'], 38 | [type='month'], 39 | [type='search'], 40 | [type='tel'], 41 | [type='time'], 42 | [type='week'], 43 | [multiple], 44 | textarea, 45 | select { 46 | @apply text-gray-700; 47 | @apply border-gray-200; 48 | @apply shadow-md; 49 | @apply rounded-md; 50 | @apply focus:border-primary; 51 | @apply focus:ring-1; 52 | @apply focus:border-primary; 53 | @apply focus:ring-primary; 54 | @apply transition-all duration-200; 55 | @apply text-sm; 56 | &:disabled { 57 | @apply text-gray-400; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting() 21 | ); 22 | // Then we find all the tests. 23 | const context = require.context('./', true, /\.spec\.ts$/); 24 | // And load the modules. 25 | context.keys().map(context); 26 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | purge: ['src/app/**/*.{html,ts}'], 3 | mode: 'jit', 4 | darkMode: false, // or 'media' or 'class' 5 | theme: { 6 | extend: { 7 | colors: { 8 | primary: 'var(--primary)', 9 | }, 10 | }, 11 | }, 12 | variants: { 13 | extend: {}, 14 | }, 15 | plugins: [require('@tailwindcss/forms')], 16 | }; 17 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitReturns": true, 10 | "noFallthroughCasesInSwitch": true, 11 | "sourceMap": true, 12 | "declaration": false, 13 | "downlevelIteration": true, 14 | "experimentalDecorators": true, 15 | "moduleResolution": "node", 16 | "importHelpers": true, 17 | "target": "es2017", 18 | "module": "es2020", 19 | "lib": [ 20 | "es2018", 21 | "dom" 22 | ] 23 | }, 24 | "angularCompilerOptions": { 25 | "enableI18nLegacyMessageIdFormat": false, 26 | "strictInjectionParameters": true, 27 | "strictInputAccessModifiers": true, 28 | "strictTemplates": true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | --------------------------------------------------------------------------------