Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link Analysis from home page #2595

Merged
merged 3 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions arrow-site/docs/_code/analysis-home-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
library: analysis
---
<!--- INCLUDE
import arrow.analysis.*
-->
{: data-executable="true"}
```kotlin
// function with pre- and post-condition
fun increment(x: Int): Int {
pre(x > 0) { "value must be positive" }
return (x + 1).post({ it > 0 }) { "result is positive" }
}

class Positive(val value: Int) {
init { require(value > 0) } // type invariant
fun add(other: Positive) =
Positive(this.value + other.value)
}
```
2 changes: 2 additions & 0 deletions arrow-site/docs/_code/core-home-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ fun prepare(tool: Knife, ingredient: Lettuce): Either<InsufficientAmountOfLettuc
-->
```kotlin
suspend fun prepareLunch(): Either<CookingException, Salad> =
// with the 'either' computation block
// we follow a "fail fast" strategy
either<CookingException, Salad> {
val lettuce = takeFoodFromRefrigerator().bind()
val knife = getKnife().bind()
Expand Down
14 changes: 9 additions & 5 deletions arrow-site/docs/_code/fx-home-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ fun employee(name: String, company: Company): Employee =
-->
```kotlin
suspend fun process(): List<Employee> {
//maps each function to `::employee` in parallel
val audrey = parZip({ "Audrey" }, { company("Arrow") }) { name, company -> Employee(name, company) }
val pepe = parZip({ "Pepe" }, { company("Arrow") }) { name, company -> Employee(name, company) }
val candidates = listOf(audrey, pepe)
return candidates.parTraverse { hire(it) } //hires in parallel
// maps to 'Employee' in parallel using 'parZip'
val audrey = parZip({ "Audrey" }, { company("Arrow") }) {
name, company -> Employee(name, company)
}
val pepe = parZip({ "Pepe" }, { company("Arrow") }) {
name, company -> Employee(name, company)
}
// hires in parallel using 'parTraverse'
return listOf(audrey, pepe).parTraverse { hire(it) }
Comment on lines +29 to +37
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check how this affects the website.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked locally, and this snippet fits exactly the side of the code block, without any scroll bars (horizontal or vertical).

Copy link
Member

@nomisRev nomisRev Jan 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for checking @serras!!

}
```
14 changes: 8 additions & 6 deletions arrow-site/docs/_code/optics-home-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ val <A> Optional<A, Street>.name: Optional<A, String>
-->
```kotlin
val john =
Employee("Audrey Tang",
Company("Arrow",
Address("Functional city",
Street(42, "lambda street"))))
Employee("Audrey Tang",
Company("Arrow",
Address("Functional City",
Street(42, "Lambda St."))))

val modified = Employee.company.address.street.name
.modify(john, String::toUpperCase)
// an optic is a reference to a piece of information
val optic = Employee.company.address.street.name
// which we then use to query or modify immutable data
val modified = optic.modify(john, String::toUpperCase)
```
8 changes: 7 additions & 1 deletion arrow-site/docs/_data/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ content:
id: core

- title: FX
description: Functional Effects Framework companion to KotlinX Coroutines.
description: Functional Effects Framework companion to KotlinX Coroutines
icon: img/home/arrow-fx-lines
url: /fx/
id: fx
Expand All @@ -23,6 +23,12 @@ content:
url: /optics/
id: optics

- title: Analysis
description: Pre-, post-condition, and invariant checks for your Kotlin code
icon: img/home/arrow-analysis-lines
url: /meta/analysis/
id: analysis

- title: Meta
description: Metaprogramming library for Kotlin compiler plugins
icon: img/home/arrow-meta-lines
Expand Down
2 changes: 1 addition & 1 deletion arrow-site/docs/_includes/_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1 id="header-text">{{site.data.commons.description}}</h1>
<div id="core-arrow-animation" class="image-animation" alt="Arrow core"></div>
<div id="fx-arrow-animation" class="image-animation" alt="Arrow fx"></div>
<div id="optics-arrow-animation" class="image-animation" alt="Arrow optics"></div>
<div id="meta-arrow-animation" class="image-animation" alt="Arrow meta"></div>
<div id="analysis-arrow-animation" class="image-animation" alt="Arrow analysis"></div>
<img id="logo-white-lines" class="image-animation" src="{{ '/img/home/logo-white-lines.svg' | relative_url }}" alt="Arrow white lines"></img>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions arrow-site/docs/_includes/_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{% for item in site.data.features.content %}
{% assign title = item.title | downcase %}
{% if item.id != "quickstart" %}
{% if item.id != "meta" %}
<a id="{{ item.id }}" class="{{ item.id }} main-item feature" href="{{ item.url | relative_url }}">
<div id="{{ item.id }}-header" class="item-header">
<div id="icon-{{ item.id }}-content" class="icon-content">
Expand All @@ -16,6 +17,7 @@ <h2 id="{{ item.id }}-title">{{ item.title }}</h2>
</div>
</a>
{% endif %}
{% endif %}
{% endfor %}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions arrow-site/docs/_sass/components/home/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
visibility: hidden;
}

#meta-code-block {
#analysis-code-block {
visibility: hidden;
}

Expand Down Expand Up @@ -165,7 +165,7 @@
right: 7px;
}

#meta-arrow-animation {
#analysis-arrow-animation {
position: absolute;
opacity: 0;
transition: $opacity-transition;
Expand Down
61 changes: 61 additions & 0 deletions arrow-site/docs/img/home/arrow-analysis-lines-color.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions arrow-site/docs/img/home/arrow-analysis-lines-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions arrow-site/docs/img/home/arrow-analysis-lines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions arrow-site/docs/js/animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,22 @@ const arrowOpticsAnimation = lottie.loadAnimation({
path: 'js/json/arrow-optics.json'
});

// meta animation
// analysis animation
const arrowAnalysisAnimation = lottie.loadAnimation({
container: document.getElementById('analysis-arrow-animation'),
renderer: 'svg' / 'canvas' / 'html',
loop: false,
autoplay: false,
path: 'js/json/arrow-analysis.json'
});


/* // meta animation
const arrowMetaAnimation = lottie.loadAnimation({
container: document.getElementById('meta-arrow-animation'),
renderer: 'svg' / 'canvas' / 'html',
loop: false,
autoplay: false,
path: 'js/json/arrow-meta.json'
});
}); */

1 change: 1 addition & 0 deletions arrow-site/docs/js/json/arrow-analysis.json

Large diffs are not rendered by default.

28 changes: 16 additions & 12 deletions arrow-site/docs/js/main-hovers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const fxArrowLogo = document.getElementById('fx-arrow-animation');
// optics elements
const opticsArrowLogo = document.getElementById('optics-arrow-animation');

// meta elements
const metaArrowLogo = document.getElementById('meta-arrow-animation');
// analysis elements
const analysisArrowLogo = document.getElementById('analysis-arrow-animation');

// Features elements
const headerCategoryRow = document.querySelectorAll('.item-header > p, .item-header > h2');
Expand Down Expand Up @@ -65,10 +65,14 @@ function checkActiveFeature(arrowFeature) {
commonHoverStyle(current_id);
opticsHoverStyle();
break;
case 'meta':
case 'analysis':
commonHoverStyle(current_id);
metaHoverStyle();
analysisHoverStyle();
break;
// case 'meta':
// commonHoverStyle(current_id);
// metaHoverStyle();
// break;
default:
baseHoverStyle();
}
Expand Down Expand Up @@ -149,7 +153,7 @@ function commonHoverStyle(id) {
footerBrandDark.style.opacity = 0;
footerBrandWhite.style.opacity = 1;
baseArrowLogo.style.opacity = 0;
siteNav.classList.remove('core', 'fx', 'meta', 'optics');
siteNav.classList.remove('core', 'fx', 'analysis', 'meta', 'optics');
arrayCategoryIconDark.map(obj => obj.style.opacity = 0);
setOpacity(arrayCategoryIconWhite, id, 0.5);
setOpacity(arrayHeaderCategoryRow, id, 0.5);
Expand All @@ -168,7 +172,7 @@ function coreHoverStyle() {
}
arrowFxAnimation.stop();
arrowOpticsAnimation.stop();
arrowMetaAnimation.stop();
arrowAnalysisAnimation.stop();
}

function fxHoverStyle() {
Expand All @@ -179,7 +183,7 @@ function fxHoverStyle() {
}
arrowCoreAnimation.stop();
arrowOpticsAnimation.stop();
arrowMetaAnimation.stop();
arrowAnalysisAnimation.stop();
}

function opticsHoverStyle() {
Expand All @@ -190,14 +194,14 @@ function opticsHoverStyle() {
}
arrowCoreAnimation.stop();
arrowFxAnimation.stop();
arrowMetaAnimation.stop();
arrowAnalysisAnimation.stop();
}

function metaHoverStyle() {
function analysisHoverStyle() {
body.style.background = "#2E3B44 url('img/home/hover-lines-header.svg') repeat-x";
metaArrowLogo.style.opacity = 1;
analysisArrowLogo.style.opacity = 1;
if (siteNav.className.includes('nav-scroll')) {
addClassName(siteNav, 'meta');
addClassName(siteNav, 'analysis');
}
arrowCoreAnimation.stop();
arrowFxAnimation.stop();
Expand Down Expand Up @@ -249,7 +253,7 @@ function mobileMode() {
arrayCategoryIconWhite.map(el => el.style.opacity = 0);
arrayCategoryIconDark.map(el => el.style.opacity = 0);
arrowBaseAnimation.stop();
siteNav.classList.remove('fx', 'meta', 'optics');
siteNav.classList.remove('fx', 'analysis', 'optics');
if (siteNav.className.includes('nav-scroll')) {
addClassName(siteNav, 'core');
}
Expand Down
10 changes: 5 additions & 5 deletions arrow-site/docs/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ function loadEvent() {
}
});

// meta elements
const metaPlayHover = document.getElementById('meta');
// analysis elements
const analysisPlayHover = document.getElementById('analysis');

metaPlayHover.addEventListener('mouseenter', () => {
analysisPlayHover.addEventListener('mouseenter', () => {
if (screenSize() > mobileModeBreakPoint) {
arrayArrowFeatures.map(obj => obj.classList.remove('active'));
metaPlayHover.classList.add('active');
analysisPlayHover.classList.add('active');
checkActiveFeature(arrayArrowFeatures);
arrowMetaAnimation.play();
arrowAnalysisAnimation.play();
arrowBaseAnimation.stop();
}
});
Expand Down
2 changes: 1 addition & 1 deletion arrow-site/docs/js/text-animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ function typeWriter(id, ar) {
}
}

Resources
// Resources