Skip to content

Commit 6720351

Browse files
committed
add doc for adding packages to pubspec.yaml
1 parent cd04cec commit 6720351

File tree

11 files changed

+201
-28
lines changed

11 files changed

+201
-28
lines changed

src/components/GoogleAnalytics.astro

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
export interface Props {
3+
id: string;
4+
}
5+
6+
const { id } = Astro.props
7+
8+
const gtagUrl = `https://www.googletagmanager.com/gtag/js?id=${id}`
9+
---
10+
<!-- Global site tag (gtag.js) - Google Analytics -->
11+
<script async src={gtagUrl}></script>
12+
13+
<script is:inline define:vars={{ id }}>
14+
window.dataLayer = window.dataLayer || []
15+
16+
function gtag() {
17+
dataLayer.push(arguments)
18+
}
19+
20+
document.addEventListener('astro:page-load', () => {
21+
gtag('js', new Date())
22+
23+
gtag('config', id)
24+
25+
}, { once: false })
26+
</script>
27+

src/components/starlight/Head.astro

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { Props } from '@astrojs/starlight/props'
33
import Default from '@astrojs/starlight/components/Head.astro'
44
import { ViewTransitions } from 'astro:transitions'
5+
import GoogleAnalytics from '../GoogleAnalytics.astro'
56
---
67

78
<Default {...Astro.props}>
@@ -10,22 +11,4 @@ import { ViewTransitions } from 'astro:transitions'
1011

1112
<ViewTransitions />
1213

13-
<!-- Google tag (gtag.js) -->
14-
<script async src="https://www.googletagmanager.com/gtag/js?id=G-3THXBRT184"></script>
15-
<script is:inline>
16-
window.dataLayer = window.dataLayer || []
17-
18-
function gtag() {
19-
dataLayer.push(arguments)
20-
}
21-
</script>
22-
23-
<script is:inline>
24-
document.addEventListener('astro:page-load', () => {
25-
gtag('js', new Date())
26-
27-
gtag('config', 'G-3THXBRT184')
28-
29-
}, { once: false })
30-
</script>
31-
14+
<GoogleAnalytics id="G-3THXBRT184" />

src/components/starlight/SocialIcons.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import {Icon} from 'astro-icon/components'
66

77
<div class="border-r border-gray-300 dark:border-gray-700 pr-4">
88
<a href="https://vyuh.tech"
9-
class={`font-bold text-accent-600 dark:text-accent-200 decoration-0 no-underline
9+
class={`font-bold decoration-0 no-underline
10+
text-accent-600 dark:text-accent-200
1011
px-2 py-0
11-
border border-gray-300 dark:border-gray-700
12-
hover:bg-accent-200 hover:dark:bg-accent-600
12+
border border-gray-300 dark:border-gray-700
13+
hover:border-accent-600 dark:hover:border-accent-200
1314
rounded
1415
inline-flex items-center`}
1516
target="_blank" rel="noopener">

src/content/docs/guides/adding-packages.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Adding Packages
33
description: Learn how to add new packages to your Vyuh project.
44
---
55

6-
import { Aside, Steps } from '@astrojs/starlight/components'
6+
import { Aside, Steps, Badge } from '@astrojs/starlight/components'
77

88
When adding packages to your Dart projects, there are two ways in which these
99
packages can be referenced inside your `pubspec.yaml`.
@@ -23,7 +23,7 @@ dependencies:
2323
For a list of all the packages which are publicly available on `pub.dev`, refer
2424
to the [article on packages](/framework/packages).
2525

26-
## Adding a package from the Enterprise Package Registry
26+
## Adding a package from the Enterprise <sup><Badge text='Plan' /></sup> Package Registry
2727

2828
Adding a package from the private pub registry requires you to set up a token
2929
for the hosted provider. You will get this `token` during the onboarding process
@@ -36,7 +36,7 @@ provider as below.
3636

3737
Keep the details of the hosted provider handy. You will need the URL of the
3838
hosted provider and the token to authenticate the requests. Let's capture
39-
these in these variables for rest of the steps:
39+
these with the following variables for rest of the steps:
4040

4141
- `<token>`: secret token to authenticate requests to the hosted provider
4242
- `<private-pub-registry>`: URL of the hosted provider

src/content/docs/guides/designing-features.mdx

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,161 @@
22
title: Designing Features
33
description: A set of tips for designing atomic and transferable features
44
---
5+
6+
import { Aside } from '@astrojs/starlight/components'
7+
8+
Designing a feature in the Vyuh framework requires putting together a bunch of
9+
elements. This includes the following:
10+
11+
- **APIs** to talk to the backend to fetch data
12+
- **Experience layer** that renders the widgets on the screen and provides User
13+
Interactivity
14+
- Distilling the **Content Blocks** that make up the feature
15+
- **Journeys** which allow the user to navigate from screen to screen in
16+
exploring the content and interacting with it in different ways
17+
- **Design system** components for a consistent experience
18+
- Client side **State management** to keep track of User interactions
19+
- **Analytics** to track user interactions and understand user behavior
20+
21+
<Aside title={'Universal Truth about Applications'}>
22+
23+
Although we talk about the **Vyuh Framework** in this article, the set of things
24+
that you have to do for building a feature for an application is _universally
25+
true_ and applicable across all applications.
26+
27+
Whether you use a low-code tool or a no-code tool, the set of things you have to
28+
do pretty much remains the same. The Vyuh Framework however makes it easier to
29+
manage both functional and non-functional aspects of building a feature. This
30+
allows you to grow from an MVP to the scale of a Super App!
31+
32+
</Aside>
33+
34+
## Core Ideas
35+
36+
Some of the core ideas of building a feature are already discussed in a separate
37+
article on [Features and Plugins](/concepts/features-and-plugins). Make sure to
38+
take a look at that before reading further.
39+
40+
In this article, we'll focus more on applying the Vyuh Framework to build a
41+
feature. This is all about distilling the feature in terms of its schemas, APIs,
42+
and experience widgets.
43+
44+
## Distilling a Feature
45+
46+
As we've already seen in the article that was referenced before, a feature is
47+
essentially a collection of screens stitched together to form a journey. The
48+
content of each screen comes from a set of content blocks that you would design
49+
and configure from a CMS.
50+
51+
![](images/feature-breakup.png)
52+
53+
Now, it's possible that these content blocks may not have a CMS counterpart, and
54+
could be driven entirely from code. But for now, let's assume for a moment that
55+
we are designing features that are CMS connected, which allows dynamic
56+
configuration and flexibility for the business teams.
57+
58+
Thus, the three core building blocks of any feature include the **APIs**, the
59+
**Content Blocks**, and **Journeys**. Let's see each of these in detail.
60+
61+
![](images/feature-parts.png)
62+
63+
### APIs
64+
65+
APIs are the primary source of data for the feature. They could be REST APIs,
66+
GraphQL APIs, or even Websockets. The APIs are responsible for fetching the data
67+
that is required to render the content blocks on the screen.
68+
69+
The APIs are also responsible for sending the user interactions back to the
70+
server for processing. This could be a simple form submission or a complex
71+
interaction that requires a series of steps to be completed.
72+
73+
The Vyuh framework has a built-in component for working with APIs, called the
74+
`APIContent`. This can be configured from the CMS, making it easier for the
75+
business teams to change the type of data source that should be used to drive
76+
the content on the screen. The API content-block simplifies the configuration
77+
needed to show content on the screen, without burdening the business teams with
78+
the implementation details of the request headers, API keys or other security
79+
parameters that are required to fetch data from the endpoint.
80+
81+
> Although we talk about APIs as the driving source of content for the content
82+
> block, it's possible that the content blocks come directly from the CMS. In
83+
> this case, they are configured on the CMS itself and rendered on the screen.
84+
85+
#### API SDKs
86+
87+
As you start working with more complex APIs and a large number of APIs, you will
88+
soon see a need to wrap all these APIs into an API SDK. The API SDK can expose a
89+
HTTP client that is used to fetch data from the server using semantic operations
90+
instead of talking directly to the endpoint URLs.
91+
92+
The use of the API SDK also hides the details of deserializing the response
93+
payloads and creating Dart objects out of them. Additionally, these API SDKs can
94+
be tested independently and made sure that they are robust enough to work under
95+
various conditions and request parameters.
96+
97+
When these APIs are commonly used across multiple features, the API SDK becomes
98+
the common package through which these features make those calls.
99+
100+
In short, think of wrapping your APIs inside an API SDK and exposing it as a
101+
common package that can be used by multiple features when needed.
102+
103+
### Content Blocks
104+
105+
While the APIs focus on fetching data from a remote endpoint, the content blocks
106+
are the key elements that allow you to render this data inside a screen. These
107+
content blocks have two counterparts:
108+
109+
- On the CMS where it exists as a schema, allowing business teams to configure
110+
it.
111+
- On the Flutter side where it exists as a widget and possibly with the
112+
combination of other elements like state management, dependency injection,
113+
analytics, etc., which will all wrap together to provide the implementation
114+
for the content block. Here is where you would also apply the **Design
115+
System** to make the widgets visually consistent.
116+
117+
<Aside title={'Design System as an SDK'}>
118+
119+
The Design System, just like the API-SDK, can be extracted into a separate
120+
package. This could be used across multiple features and even across apps if
121+
they are maintaining a similar visual identity.
122+
123+
It's probably a good idea to start building your design system (themes, colors,
124+
typography, icons, spacings, and of course the UI components) into a separate
125+
package so it becomes more reusable across features & apps.
126+
127+
</Aside>
128+
129+
### Journeys
130+
131+
Now we have included journeys as part of a feature which is purely from a
132+
customer's perspective.
133+
134+
However, when we work with the Vyuh Framework, we think of the journeys as not
135+
being hardcoded into the feature itself. Instead, they are defined and
136+
configured from the CMS. This gives the business the ability to change the
137+
journeys on the fly depending on the type of customer,
138+
139+
Externalizing the journeys is one of the key elements of the Vyuh Framework.
140+
With that, the features themselves only have to expose a set of content blocks,
141+
which are configured from the CMS. The business teams will use the content
142+
blocks to assemble pages and then stitch them together through a navigation
143+
journey.
144+
145+
<Aside title={'Fixed Journeys'}>
146+
147+
However, there are cases where a journey is so fixed in nature that it doesn't
148+
require a special type of configuration from the CMS. The payment journey is one
149+
such example.
150+
151+
Once you check out from your cart, the payment journey begins and accepts your
152+
payment method, then takes you additional screens for more details, and finally
153+
completes the secure transaction. It then takes you back to the confirmation
154+
page. This journey can be hard-coded into the feature itself.
155+
156+
</Aside>
157+
158+
## Summary
159+
160+
This guide has provided a set of tips for designing your features by identifying
161+
its core components. By applying these ideas you can even make features that
162+
work across a family of Vyuh Apps.
Loading
81.6 KB
Loading
-461 KB
Binary file not shown.

src/tailwind.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
.mobile-preferences {
66
@apply items-center justify-center;
7-
}
7+
}
8+

tailwind.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ const gray = {
2222
export default {
2323
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
2424
theme: {
25-
colors: { accent, gray },
25+
extend: {
26+
colors: { accent, gray },
27+
},
2628
},
2729
plugins: [starlight()],
2830
}

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"jsx": "react-jsx",
66
"jsxImportSource": "react",
77
"paths": {
8-
"@/*": ["./src/*"]
8+
"@/*": ["./src/*"],
9+
"@docs/*": ["./src/content/docs/*"]
910
}
1011
},
1112
}

0 commit comments

Comments
 (0)