Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

Commit

Permalink
structure (#7)
Browse files Browse the repository at this point in the history
implement new file structure which is allowing to import single components from the package
  • Loading branch information
tlaziuk committed Nov 8, 2016
1 parent 0f0f1ce commit 8b66b94
Show file tree
Hide file tree
Showing 27 changed files with 89 additions and 89 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ tags
**.js
**.d.ts
**.map
**.gz
9 changes: 7 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ node_modules
#system
tags
#project
**.ts
!**.d.ts
*.spec.*
*.conf.*
*.webpack.*
*.json
*.yml
.editorconfig
*.html
2 changes: 1 addition & 1 deletion test/async.test.ts → async.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { promiseFn } from '../src/async'
import { promiseFn } from './async'

describe(`async`, () => {
it(`expect ${promiseFn} to exists`, (done: Function) => {
Expand Down
File renamed without changes.
35 changes: 32 additions & 3 deletions test/carousel.test.ts → carousel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
import { Carousel, Mode, Orientation } from '../src/index'
import { size } from '../src/size'
import { tree } from './carousel.spec'
import { Carousel, Mode, Orientation } from './index'
import { size } from './size'

export interface TreeInterface {
parent: HTMLElement
container: HTMLUListElement
element: HTMLLIElement[]
}

export function tree(parentElement: HTMLElement, count: number = 8, width: number = 200, height: number = 100, childSize: number = Math.min(width, height) / 2): TreeInterface {
let container = document.createElement(`ul`)
parentElement.appendChild(container)
container.style.width = `${width}px`
container.style.height = `${height}px`
container.style.position = `relative`
let element: HTMLLIElement[] = []
let counter = 0
while (counter < count) {
counter++
let el = document.createElement(`li`)
el.style.width = `${childSize}px`
el.style.height = `${childSize}px`
el.style.position = `absolute`
container.appendChild(el)
element.push(el)
}
return {
parent: parentElement,
container: container,
element: element,
}
}

describe(`Carousel`, () => {
it(`expect Carousel to be not undefined`, (done: Function) => {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/element.test.ts → element.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { element } from '../src/element'
import { element } from './element'

const selector = `html`
const badSelector = Number.NaN
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions test/index.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>

<head>
<script src="../dist/carouselic.js"></script>
<script src="./carouselic.js"></script>
<style type="text/css">
* {
box-sizing: border-box;
Expand Down Expand Up @@ -30,7 +30,7 @@
margin: 0px;
padding: 0px;
border: red 1px solid;
/* animation: 5s linear 0s infinite alternate rect; */
animation: 5s linear 0s infinite alternate rect;
}

ul li {
Expand Down Expand Up @@ -79,6 +79,9 @@
var carousel = new Carouselic(document.getElementById('carouselic'), {
childSelector: 'li',
});
setInterval(function() {
carousel.move()
}, 500)
</script>
</body>

Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions index.webpack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Carousel } from './carousel'

import './mod/globalize'
import './mod/resize'
import './mod/wheel'
6 changes: 3 additions & 3 deletions karma.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ module.exports = (config: karma.Config) => {
included: true,
},
{
pattern: `src/**/*.ts`,
pattern: `mod/!(webpack|conf).ts`,
included: true,
},
{
pattern: `test/**/*.ts`,
pattern: `!(*.webpack|*.conf).ts`,
included: true,
},
],
Expand Down Expand Up @@ -46,7 +46,7 @@ module.exports = (config: karma.Config) => {
},
remapOptions:
{
exclude: /\.(spec|test|d)\.ts/i,
exclude: /\.(spec|test|d|conf|webpack)\.ts/i,
},
},
} as karma.ConfigOptions)
Expand Down
2 changes: 1 addition & 1 deletion src/globalize.mod.ts → mod/globalize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Carousel } from './carousel'
import { Carousel } from '../carousel'

if (window) {
(window as any).Carouselic = Carousel
Expand Down
4 changes: 2 additions & 2 deletions src/resize.mod.ts → mod/resize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Carousel } from './carousel'
import { on, CarouselEvent } from './event'
import { Carousel } from '../carousel'
import { on, CarouselEvent } from '../event'

if (window) {
on(CarouselEvent.init, function(this: Carousel) {
Expand Down
8 changes: 4 additions & 4 deletions test/wheel.test.ts → mod/wheel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Carousel, Mode, Orientation } from '../src/index'
import '../src/wheel.mod'
import { tree } from './carousel.spec'
import { on, CarouselEvent } from '../src/event'
import { Carousel } from '../carousel'
import '../mod/wheel'
import { tree } from '../carousel.spec'
import { on, CarouselEvent } from '../event'

describe(`wheel`, () => {
it(`expect Carousel to have wheel method`, (done: Function) => {
Expand Down
8 changes: 4 additions & 4 deletions src/wheel.mod.ts → mod/wheel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Carousel } from './carousel'
import { eventFn } from './async'
import { CarouselEvent } from './event'
import { Carousel } from '../carousel'
import { eventFn } from '../async'
import { CarouselEvent } from '../event'

export function wheel(this: Carousel) {
if (!this._wheel) {
Expand All @@ -18,7 +18,7 @@ export function wheel(this: Carousel) {
Carousel.prototype.wheel = wheel
Carousel.prototype._wheel = false

declare module './carousel' {
declare module '../carousel' {
interface Carousel {
wheel: typeof wheel
_wheel: boolean
Expand Down
File renamed without changes.
File renamed without changes.
31 changes: 12 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
{
"name": "carouselic",
"version": "0.4.0",
"version": "1.0.0",
"description": "TypeScript carousel",
"main": "src/index.js",
"typings": "src/index.d.ts",
"files": [
"src/",
"dist/"
],
"directories": {
"lib": "src",
"test": "test"
},
"main": "index.js",
"typings": "index.d.ts",
"scripts": {
"build": "npm run tsc && npm run bundle",
"build": "npm run tsc && npm run bundle && npm run bundle:compress",
"bundle": "webpack --config webpack.conf.js",
"bundle:compress": "for c in carouselic*js; do gzip -c -9 -v \"$c\" > \"$c.gz\"; done",
"bundle:w": "webpack --config webpack.conf.js --watch",
"clean": "git clean -Xf",
"coveralls": "for lcov in coverage/*/lcovonly; do cat \"$lcov\" | coveralls; done",
"lint": "find . -name '*.ts' -print | grep -v .d.ts | grep -v node_modules | xargs tslint -t verbose",
"prepublish": "npm run clean && npm run build",
"test": "karma start",
"test:d": "karma start --no-auto-watch --no-single-run",
"test:w": "karma start --auto-watch --no-single-run",
"tsc": "tsc",
"tsc:w": "tsc -w",
"bundle": "webpack --config webpack.config.js",
"bundle:w": "webpack --config webpack.config.js --watch"
"test": "karma start ./karma.conf.js",
"test:d": "karma start ./karma.conf.js --no-auto-watch --no-single-run",
"test:w": "karma start ./karma.conf.js --auto-watch --no-single-run",
"tsc": "tsc --p ./tsconfig.json",
"tsc:w": "tsc --p ./tsconfig.json -w"
},
"repository": {
"type": "git",
Expand Down
File renamed without changes.
7 changes: 0 additions & 7 deletions src/index.webpack.ts

This file was deleted.

29 changes: 0 additions & 29 deletions test/carousel.spec.ts

This file was deleted.

File renamed without changes.
15 changes: 8 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
]
},
"include": [
"**/*.conf.ts",
"**/*.config.ts",
"**/*.mod.ts",
"**/*.web.ts",
"**/*.webpack.ts",
"src/index.ts"
]
"**/*.ts"
],
"exclude": [
"node_modules",
"**/*.spec.ts",
"**/*.webpack.ts"

]
}
7 changes: 3 additions & 4 deletions webpack.config.ts → webpack.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ import * as webpack from 'webpack'

module.exports = {
entry: {
'carouselic': `./src/index`,
'carouselic.min': `./src/index`,
'carouselic': `./index`,
'carouselic.min': `./index`,
},
output: {
filename: `./dist/[name].js`,
filename: `./[name].js`,
},
devtool: `source-map`,
resolve: {
extensions: [
``,
`.webpack.ts`,
`.web.ts`,
`.ts`,
],
},
Expand Down

0 comments on commit 8b66b94

Please sign in to comment.